数据类型这一节遇到的问题
请问大神,在sizeof运算符这一节,我照着书上的输入,字母和符号都没有错,结果一运行出现错误:http://m.qpic.cn/psc?/dc4b0554-7ab7-427e-9f3a-2bb6da2d84ee/TmEUgtj9EK6.7V8ajmQrEAJe8uauUxW6H.pfwPlo2SHc4ea.fBARxBx0NaCn0SWnugVQAeZuWSb118.wXHSp1OjE08BqNQPesRzKKHd9q5s!/b&bo=CwMjAQAAAAADFxg!&rf=viewer_4 发代码 大马强 发表于 2021-9-28 16:17
发代码
#include <stdio.h>
int main(void)
{
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;
} 你输出括号都不打干净,当然错啦 a327904410 发表于 2021-9-28 17:52
你输出括号都不打干净,当然错啦
第三行的输出结尾少了个括号 1. 括号漏写
2.字符要用单引号,字符串用双引号
#include <stdio.h>
int main(void)
{
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;
}
页:
[1]