1 #include
2 typedef char * STR;
3
4 int main(void)
5 {
6 STR s="helloworld!";
7 printf("%s\n", s);
8 printf("%d%d%d\n", -10<-11<0, -10<-1<0, -10<1<0);
9 int a[3][6];
10 printf("sizeof(int):%d, sizeof(a[0]):%ld\n",sizeof(int), sizeof(a[0]));
11 return 0;
12 }
13
运行结果如下:
zh@zh-CW65S:~/work$ gcc test.c
test.c: In function ‘main’:
test.c:10:2: warning: format ‘%d’ expects argument of type ‘int’, but argument 2 has type ‘long unsigned int’ [-Wformat=]
printf("sizeof(int):%d, sizeof(a[0]):%ld\n",sizeof(int), sizeof(a[0]));
^
zh@zh-CW65S:~/work$ ./a.out
helloworld!
000
sizeof(int):4, sizeof(a[0]):24
第一问
typedef char * STR;
第二问
24
a[0] 是指 sizeof(a[0][0]+a[0][1]+a[0][2]+a[0][3]+a[0][4]+a[0][5])
所以 4*6=24
#typedef STR char*
0
4
typedef char * STR
0
24