fork download
  1. #include<stdio.h>
  2. #include<stdlib.h>
  3. int main()
  4. {
  5. int array[] = {1, 2, 3};
  6. int *iptr = &array[0];
  7. int num = *iptr++;//1) In this expression the value of 'i' is assigned to num. And an attempt of post incrementing the address stored in *iptr is done as side effect.
  8. printf("Num value: %d\n",num);
  9.  
  10. printf("Pointer: %p\n", (void*)iptr);//2) The address of *iptr is not incremented. If it was then the value of 'i' would not be printed instead it would print the incremented address itself.
  11.  
  12. printf("Post increment: %p\n", (void*)iptr++);//3) The address of *iptr will be post incremented (which didn't happen in case of num). But for now the value of 'i' will be printed.
  13.  
  14. printf("After increment: %p\n",(void*)iptr);//4) Now the incremented address stored in *iptr will be displayed as there is no value assigned to that address.
  15. return 0;
  16. }
  17.  
Success #stdin #stdout 0s 10320KB
stdin
Standard input is empty
stdout
Num value: 1
Pointer: 0x7fffddc5b594
Post increment: 0x7fffddc5b594
After increment: 0x7fffddc5b598