Advertisement
kk258966

資料結構

Mar 11th, 2015
246
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.88 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. int main(void){
  4.   int a=1;  
  5.   double b=2.0;
  6.   char c='A';
  7.  
  8.   int* ptr1;
  9.   double* ptr2;
  10.   char* ptr3;
  11.  
  12.   ptr1=&a;
  13.   ptr2=&b;
  14.   ptr3=&c;  
  15.    
  16.   printf("sizeof(a)%d\n",sizeof(a));
  17.   printf("sizeof(b)%d\n",sizeof(b));
  18.   printf("sizeof(c)%d\n",sizeof(c));
  19.  
  20.   printf("\n====================================\n");
  21.  
  22.   printf("address of a %p\n",&a);
  23.   printf("address of b %p\n",&b);
  24.   printf("address of c %p\n",&c);
  25.  
  26.   printf("\n====================================\n");
  27.  
  28.   printf("the value of ptr1 %p\n",ptr1);
  29.   printf("the value of ptr2 %p\n",ptr2);
  30.   printf("the value of ptr3 %p\n",ptr3);
  31.  
  32.   printf("\n====================================\n");
  33.  
  34.   printf("the value of a %d\n",*ptr1);
  35.   printf("the value of b %.2f\n",*ptr2);
  36.   printf("the value of c %c\n",*ptr3);
  37.      
  38.   system("PAUSE");
  39.   return 0;  
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement