/* * Program to experiment with pointer variables and arithmetic */ #include #include int main() { int i, *ip, **ipp; char c, *cp, **cpp; double d, *dp; // Initialize some variables i = 268; c = 'a'; ip = NULL; // What values reside in the uninitialized variable? printf("Variable values: c=%c, i=%d, ip=%x, cp=%x, ipp=%x, cpp=%x\n", c, i, ip, cp, ipp, cpp); // pointer assignments ip = &i; //cp = &i; // Is this allowed? cp = &c; //ipp = &i; // Is this allowed? ipp = &ip; cpp = &cp; dp = &d; printf("Pointer values after assignment: ip=%x, *ip=%d, &ip= %x, *ipp=%x, **ipp=%d\n", ip, *ip, &ip, *ipp, **ipp); // Operations on pointer variables printf("Values in pointer variables: cp=%u, ip=%u, cpp=%u, ipp=%u, dp=%u\n", cp, ip, cpp, ipp, dp); cp++; ip++; cpp++; ipp++; dp++; printf("Values after increment : cp=%u, ip=%u, cpp=%u, ipp=%u, dp=%u\n", cp, ip, cpp, ipp, dp); return 0; }