+ 3
If the pointer is decremented by 1, will the memory address decreases by 4 (int)?
#include <stdio.h> int main() { int a[5] = {22, 33, 44, 55, 66}; int *ptr = NULL; ptr = &a[4]; /* point to the fifth array element */ printf("%d %x\n", *ptr, ptr); /* 66 */ ptr--; printf("%d %x\n", *ptr, ptr); /* 55 */ return 0; } /*If the pointer is decremented by 1, will the memory address decreases by 4 (int)? */
4 Respuestas
+ 2
You already got your answer from your program, 4
+ 2
Ok
+ 2
Yes
+ 1
That is like your other question something you can figure out by checking this in Playground!
Increment the adress, print it out, compare it. Then try it with shorts or another type.