Pointer
Declaration and initialization
int * p;
p = NULL;
Address of ordinary variable declaration
int data;
data = 0;
printf("data address = %p\n", &data);
Substitute the address of the variable into the address declared variable
int * p;
int data;
p = NULL;
printf("Before : p address = %p\n", p);
data = 0;
p = &data;
printf("After : p address = %p\n", p);
printf("data address = %p\n", &data);
Changing the value via a pointer
int * p;
int data;
p = NULL;
data = 10;
p = &data;
printf("Before : data value = %d\n", data);
*p = 20;
printf("After : data value = %d\n", data);
Pointer of pointer
int * p, ** pp;
int data = 10;
p = NULL, pp = NULL;
p = &data;
pp = &p;
printf("*pp = %p\n", *pp);
printf("&p = %p\n", &p);
printf("p = %p\n", p);
printf("&date = %p\n", &data);
printf("*p = %d\n", *p);
printf("**p = %d\n", **pp);
**pp = 20;
printf("date = %d\n", date);
Struct pointer
struct TEST {
int age;
char[255] name;
int phone;
};
TEST test;
TEST *testp;
testp = &test;
testp -> age = 20;
testp -> phone = 080;