Advertisement
math230

Practice with pointers 1

Sep 6th, 2019
620
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.28 KB | None | 0 0
  1. int main(){
  2.   int num=8, x=53, *xp;
  3.  
  4.   xp = &x;
  5.   num = *xp;
  6.  
  7.   printf("addr of x is %p  \n", &x);
  8.   printf("value of xp is %p\n", xp);
  9.   printf("*xp is %d, x is %d\n", *xp, x);
  10.  
  11.   *xp = *xp + 1;   //same as x = x +1
  12.   printf(" *xp is %d, x is %d\n", *xp, x);
  13.    
  14.   return 0;
  15. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement