0
Which is used pointer in c program?
#include <stdio.h> int main() { int a[5] = {22, 33, 44, 55, 66}; int *ptr = NULL; ptr = a; /* point to the first array element */ printf("%d %x\n", *ptr, ptr); /* 22 */ ptr++; printf("%d %x\n", *ptr, ptr); /* 33 */ ptr += 3; printf("%d %x\n", *ptr, ptr); /* 66 */ ptr--; printf("%d %x\n", *ptr, ptr); /* 55 */ ptr -= 2; printf("%d %x\n", *ptr, ptr); /* 33 */ }
2 Antworten
+ 4
You created ptr pointer and value is null printf statement you printing value *(ptr +0 ) which represent first index of array so 22 will print and %x use for hex values and ptr printing address in hex form .
After that ptr++ which increse the index same 33 will print and ptr for address
....
44
...
66 and address.
Hope you understood
0
I dont understand the question. Code seems to work as it should.