0
How the address of a variable is affected by arithmetic oprators
c = 500; //let address of c be 2004 ptr = &c; printf("%d", ptr + 1); printf("%d ", *(ptr + 2)); printf("%d", ptr - 1); // so what will be outputs and why??
2 ответов
+ 1
Depends on the type of c. Assuming it is an int and is 4 bytes, the first output will be 2008. The second will be undefined behaviour because you are reading at an invalid memory address. The third will print 2000. This is because adding 1 to pre will increase its value by sizeof int which is 4
0
@The Man thanks for answering. So, according to you the first one will be 2008??