Advertisement
luizaspan

Pointers

Jul 2nd, 2015
503
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.42 KB | None | 0 0
  1. #include <stdio.h>
  2.  
  3. int main(void)
  4. {
  5.     float a=3.0, b[2]={1,2}, *p1, *p2;
  6.  
  7.     printf("%p %p \n",&a,&b[0]);
  8.  
  9.     p1=&a;
  10.     p2=&b[0];
  11.  
  12.     printf("%p %p %f %f \n",p1,p2,*p1,*p2);
  13.  
  14.     p2=p2+1; // pula pro proximo espaço da memoria
  15.  
  16.     printf("%p %p %f %f \n",p1,p2,*p1,*p2);
  17.  
  18.     p1=p2;
  19.  
  20.     printf("%p %p %f %f \n",p1,p2,*p1,*p2);
  21.  
  22.     p2=b; // b é igual a &b[0]
  23.     *p1=*p2;
  24.  
  25.     printf("%p %p %f %f \n",p1,p2,*p1,*p2);
  26.  
  27.     return 0;
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement