|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
#include <stdio.h>
int main()
{
int i;
char j;
float k;
i = 123;
j = 'c';
k = 3.14;
printf("size of int is %d\n", sizeof(int));
printf("size of i is %d\n", sizeof(i));
printf("size of char is %d\n", sizeof(char));
printf("size of j is %d\n", sizeof j);
printf("size of float is %d\n", sizeof(float));
printf("size of k is %d\n", sizeof k);
return 0;
}
分割
test.c:13:35: warning: format specifies type 'int' but the argument has type
'unsigned long' [-Wformat]
printf("size of int is %d\n", sizeof(int));
~~ ^~~~~~~~~~~
%lu
test.c:14:33: warning: format specifies type 'int' but the argument has type
'unsigned long' [-Wformat]
printf("size of i is %d\n", sizeof(i));
~~ ^~~~~~~~~
%lu
test.c:15:36: warning: format specifies type 'int' but the argument has type
'unsigned long' [-Wformat]
printf("size of char is %d\n", sizeof(char));
~~ ^~~~~~~~~~~~
%lu
test.c:16:33: warning: format specifies type 'int' but the argument has type
'unsigned long' [-Wformat]
printf("size of j is %d\n", sizeof j);
~~ ^~~~~~~~
%lu
test.c:17:37: warning: format specifies type 'int' but the argument has type
'unsigned long' [-Wformat]
printf("size of float is %d\n", sizeof(float));
~~ ^~~~~~~~~~~~~
%lu
test.c:18:33: warning: format specifies type 'int' but the argument has type
'unsigned long' [-Wformat]
printf("size of k is %d\n", sizeof k);
~~ ^~~~~~~~
%lu
6 warnings generated.
你的编译器非常古怪,像下面这样修改试试看
- printf("size of int is %d\n", (int) sizeof(int)) ;
- printf("size of i is %d\n", (int) sizeof(i)) ;
- printf("size of char is %d\n", (int) sizeof(char)) ;
- printf("size of j is %d\n", (int) sizeof(j)) ;
- printf("size of float is %d\n", (int) sizeof(float)) ;
- printf("size of k is %d\n", (int) sizeof(k)) ;
复制代码
不过,都是警告信息,应该不会影响代码的编译和正常运行
|
|