Advertisement
kk258966

11/28 進階程式設計 練習一

Nov 28th, 2014
212
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.68 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. int main(void)
  4. {
  5.     int no[10],i;
  6.     int *ptr=no;
  7.     no[1]=5;
  8.     no[2]=10;
  9.     no[3]=15;
  10.     no[4]=20;
  11.     no[5]=25;
  12.    
  13.     for(i=1;i<=5;i++)
  14.        {
  15.                      ptr=&no[i];
  16.                      printf("no[%d]值:(%d),位址:(%p)\n",i,no[i],ptr);
  17.                      printf("ptr值:(%p),ptr位址:(%p)\n",ptr,&ptr);
  18.        }
  19.        
  20.        
  21.        printf("\n========================================\n");
  22.          i=1;
  23.          
  24.          ptr=&no[i];
  25.          printf("no[%d]值:(%d),位址:(%p)\n",i,no[i],ptr);
  26.          printf("ptr值:(%p),ptr位址:(%p)\n",ptr,&ptr);
  27.  
  28.     system("pause");
  29.     return 0;
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement