|
发表于 2009-10-15 11:22:35
|
显示全部楼层
怎么说呢?楼主有点自作聪明。
至少我从理论和实践都表明答案就是24,32,48。
而且,楼主看到了,我的cc都是一切缺省参数。没有附加任何选项。
我的平台:ubuntu 8.04.3, gcc 4.2.4
- poet:/tmp$ cat 1.c
- int main(void)
- {
- int var1=0;
- char var2=0;
- int var3=0;
- char str_val1[]="24\n";
- char str_val2[]="32\n";
- char str_val3[]="48\n";
- sscanf(str_val1,"%d",&var1);
- sscanf(str_val2,"%d",&var2);
- sscanf(str_val3,"%d",&var3);
- printf("var1=%d,var2=%d,var3=%d\n",var1,var2,var3);
- }
- poet:/tmp$ make 1
- cc 1.c -o 1
- 1.c: In function ‘main’:
- 1.c:9: warning: incompatible implicit declaration of built-in function ‘sscanf’
- 1.c:12: warning: incompatible implicit declaration of built-in function ‘printf’
- poet:/tmp$ ./1
- var1=24,var2=32,var3=48
- Segmentation fault (core dumped)
- poet:/tmp$
复制代码 |
|