fork download
  1. #include <stdio.h>
  2.  
  3. int main(void)
  4. {
  5. int *zPtr;
  6. int *aPtr = NULL;
  7. void *sPtr = NULL;
  8. int number;
  9.  
  10. int z[5] =
  11. { 1, 2, 3, 4, 5 };
  12.  
  13. zPtr = z;
  14. sPtr = z;
  15.  
  16. ++zPtr;
  17.  
  18. number = *zPtr;
  19.  
  20. printf("The value pointed to by zPtr is: %d\n",
  21. number);
  22.  
  23. number = zPtr[2];
  24.  
  25. printf("The value of zPtr[2] is: %d\n",
  26. number);
  27.  
  28. printf("The complete array is:\n");
  29.  
  30. for (int i = 0; i < 5; ++i)
  31. {
  32. printf("%d\t", zPtr[i - 1]);
  33. }
  34.  
  35. puts("");
  36.  
  37. number = *((int *)sPtr);
  38.  
  39. printf("The value pointed to by sPtr is: %d\n",
  40. number);
  41.  
  42. int *newPtr = z;
  43.  
  44. ++newPtr;
  45.  
  46. printf("The value after moving the pointer is: %d\n",
  47. *newPtr);
  48.  
  49. return 0;
  50. }
Success #stdin #stdout 0.01s 5284KB
stdin
Standard input is empty
stdout
The value pointed to by zPtr is: 2
The value of zPtr[2] is: 4
The complete array is:
1	2	3	4	5	
The value pointed to by sPtr is: 1
The value after moving the pointer is: 2