I'm trying to learn how to use the pointer in a C program; my example is as follows:
#include <stdio.h>
#include <stdlib.h>
int main(int argc, char *argv[]) {
int * tab = (int*)malloc(sizeof(int)*5);
int a = 10;
int *p;
p = &a;
printf("the address of a is %d \n",&a);
printf("the address of a using the pointer is %p \n",p);
printf("the address of tab is %d \n",tab);
}
I'm trying to print the address of a
, the address value inside of p
and where the first byte of the tab
begins.
I can get hexadecimal values when using "%p"
, but I'm willing the decimal value of the addresses.
Edit : On this Video image, someone has used "%d"
to print a decimal value for a pointer address, and it has confused me.