fork download
  1. #include <stdio.h>
  2.  
  3. int main() {
  4.  
  5. int a = 10;
  6. float f = 3.5;
  7. char c = 'A';
  8.  
  9. int *p1 = &a;
  10. float *p2 = &f;
  11. char *p3 = &c;
  12.  
  13. printf("Initial Addresses:\n");
  14. printf("p1 (int) = %p\n", p1);
  15. printf("p2 (float)= %p\n", p2);
  16. printf("p3 (char) = %p\n\n", p3);
  17. p1++;
  18. p2++;
  19. p3++;
  20. printf("After Increment (++):\n");
  21. printf("p1 = %p (int +4 bytes)\n", p1);
  22. printf("p2 = %p (float +4 bytes)\n", p2);
  23. printf("p3 = %p (char +1 byte)\n\n", p3);
  24. p1--;
  25. p2--;
  26. p3--;
  27. printf("After Decrement (--):\n");
  28. printf("p1 = %p (int -4 bytes)\n", p1);
  29. printf("p2 = %p (float -4 bytes)\n", p2);
  30. printf("p3 = %p (char -1 byte)\n", p3);
  31.  
  32. return 0;
  33. }
  34.  
Success #stdin #stdout 0s 5324KB
stdin
Standard input is empty
stdout
Initial Addresses:
p1 (int)  = 0x7ffd78844cf0
p2 (float)= 0x7ffd78844cf4
p3 (char) = 0x7ffd78844cef

After Increment (++):
p1 = 0x7ffd78844cf4 (int +4 bytes)
p2 = 0x7ffd78844cf8 (float +4 bytes)
p3 = 0x7ffd78844cf0 (char +1 byte)

After Decrement (--):
p1 = 0x7ffd78844cf0 (int -4 bytes)
p2 = 0x7ffd78844cf4 (float -4 bytes)
p3 = 0x7ffd78844cef (char -1 byte)