Advertisement
dmilicev

pointers.c

Nov 23rd, 2021
668
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.21 KB | None | 0 0
  1. /*
  2.  
  3.     pointers.c
  4.  
  5.  
  6.     You can find all my C programs at Dragan Milicev's pastebin:
  7.  
  8.     https://pastebin.com/u/dmilicev
  9.  
  10. */
  11.  
  12. #include <stdio.h>
  13.  
  14. int main(void){
  15.     int x, y;
  16.     int *px, *py;
  17.  
  18.     x = 10;
  19.     y = 20;
  20.  
  21.     px = &x;
  22.     py = &y;
  23.  
  24.     printf("\n Address of x variable: %p \n", &x);
  25.     printf("\n Address of y variable: %p \n\n", &y);
  26.  
  27.     printf("\n Address stored in px variable: %p \n", px);
  28.     printf("\n Address stored in py variable: %p \n\n", py);
  29.  
  30.     printf("\n Address of x variable: %x \n", &x);
  31.     printf("\n Address of y variable: %x \n\n", &y);
  32.  
  33.     printf("\n Address stored in px variable: %x \n", px);
  34.     printf("\n Address stored in py variable: %x \n\n", py);
  35.  
  36.     printf("\n Value of px variable: %d \n", *px);
  37.     printf("\n Value of py variable: %d \n\n", *py);
  38.  
  39.     printf("\n\n");
  40.     return 0;
  41. } // main()
  42.  
  43. /*
  44.     Sample output:
  45.  
  46.  
  47.  Address of x variable: 0022FF14
  48.  
  49.  Address of y variable: 0022FF10
  50.  
  51.  
  52.  Address stored in px variable: 0022FF14
  53.  
  54.  Address stored in py variable: 0022FF10
  55.  
  56.  
  57.  Address of x variable: 22ff14
  58.  
  59.  Address of y variable: 22ff10
  60.  
  61.  
  62.  Address stored in px variable: 22ff14
  63.  
  64.  Address stored in py variable: 22ff10
  65.  
  66.  
  67.  Value of px variable: 10
  68.  
  69.  Value of py variable: 20
  70.  
  71. */
  72.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement