diff --git a/check_pointer.c b/check_pointer.c new file mode 100644 index 0000000..cc94dee --- /dev/null +++ b/check_pointer.c @@ -0,0 +1,61 @@ +#include + +int main() +{ + int a = 1; + int b = 2; + int c = 3; + int d = 4; + + int *pa = &a; + int *pb = &b; + int **ppa = &pa; + int **ppb = &pb; + + printf("%x %x\n", &a, a); + printf("%x %x\n", &b, b); + printf("%x %x\n", &c, c); + printf("%x %x\n", &d, d); + printf("%x %x %x\n", &pa, pa, *pa); + printf("%x %x %x\n", &pb, pb, *pb); + printf("%x %x %x %x\n", &ppa, ppa, *ppa, **ppa); + printf("%x %x %x %x\n", &ppb, ppb, *ppb, **ppb); + + ppa = &pb; + ppb = &pa; + + printf("%x %x\n", &a, a); + printf("%x %x\n", &b, b); + printf("%x %x\n", &c, c); + printf("%x %x\n", &d, d); + printf("%x %x %x\n", &pa, pa, *pa); + printf("%x %x %x\n", &pb, pb, *pb); + printf("%x %x %x %x\n", &ppa, ppa, *ppa, **ppa); + printf("%x %x %x %x\n", &ppb, ppb, *ppb, **ppb); + + *ppa = &c; + *ppb = &d; + + printf("%x %x\n", &a, a); + printf("%x %x\n", &b, b); + printf("%x %x\n", &c, c); + printf("%x %x\n", &d, d); + printf("%x %x %x\n", &pa, pa, *pa); + printf("%x %x %x\n", &pb, pb, *pb); + printf("%x %x %x %x\n", &ppa, ppa, *ppa, **ppa); + printf("%x %x %x %x\n", &ppb, ppb, *ppb, **ppb); + + **ppa = 5; + **ppb = 6; + + printf("%x %x\n", &a, a); + printf("%x %x\n", &b, b); + printf("%x %x\n", &c, c); + printf("%x %x\n", &d, d); + printf("%x %x %x\n", &pa, pa, *pa); + printf("%x %x %x\n", &pb, pb, *pb); + printf("%x %x %x %x\n", &ppa, ppa, *ppa, **ppa); + printf("%x %x %x %x\n", &ppb, ppb, *ppb, **ppb); + + return 0; +}