1 #include <stdio.h>
2
3 int main(void){
4
5 printf("----- size ---------\n");
6 printf("\tchar\t%d\n", sizeof(char));
7 printf("\tint\t%d\n", sizeof(int));
8 printf("\tdouble\t%d\n", sizeof(double));
9
10 return 0;
11 }
----- size ---------
char 1
int 4
double 8
1 #include <stdio.h>
2
3 int main(void){
4
5 double x=-7.696151733398438e-4;
6 int i=55;
7 char a='a';
8 unsigned char *p;
9
10 printf("--- char a ---------------\n");
11 printf("%p\t%02x\n", &a, a);
12
13 p=(unsigned char *)&i;
14
15 printf("--- int i ----------------\n");
16 printf("%p\t%02x\n", p, p[0]);
17 printf("%p\t%02x\n", p+1, p[1]);
18 printf("%p\t%02x\n", p+2, p[2]);
19 printf("%p\t%02x\n", p+3, p[3]);
20
21 p=(unsigned char *)&x;
22
23 printf("--- double x -------------\n");
24 printf("%p\t%02x\n", p, p[0]);
25 printf("%p\t%02x\n", p+1, p[1]);
26 printf("%p\t%02x\n", p+2, p[2]);
27 printf("%p\t%02x\n", p+3, p[3]);
28 printf("%p\t%02x\n", p+4, p[4]);
29 printf("%p\t%02x\n", p+5, p[5]);
30 printf("%p\t%02x\n", p+6, p[6]);
31 printf("%p\t%02x\n", p+7, p[7]);
32
33 return 0;
34 }
--- char a ---------------
0xbffff6ab 61
--- int i ----------------
0xbffff6ac 37
0xbffff6ad 00
0xbffff6ae 00
0xbffff6af 00
--- double x -------------
0xbffff6b0 00
0xbffff6b1 00
0xbffff6b2 00
0xbffff6b3 00
0xbffff6b4 00
0xbffff6b5 38
0xbffff6b6 49
0xbffff6b7 bf
ホームページ:
Yamamoto's laboratory著者:
山本昌志
Yamamoto Masashi
平成19年5月23日