D:\Devcppworkspace\ch04\试卷T13.c [Warning] format '%c' expects argument of type 'int', but argument 2 has type 'char *' [-Wformat=]为什么会报了这个错%c不可以是char类型吗!
#include
int main(){
printf("%c","a");
return 0;
}
%c代表char的符号,%d是int,%f是float,%lf是double,%lld是long long,%s是字符串。
C语言有严格的要求,单引号必定是char,只能容纳一个字符,双引号是字符串。
应改为:printf("%c", 'a');
如果对你有帮助,还请帮忙点个采纳,谢谢!
"a"是字符串,相当于char*类型,不是char类型,不能用%c输出的,要改为%s
或者是printf("%c",'a');用单引号的是字符char
#include <stdio.h>
int main()
{
printf("%c", 'a');
return 0;
}
输出结果:
a
5.如果还有什么不懂得,可以私我。。。
供参考:https://wenku.baidu.com/view/b9924b54f142336c1eb91a37f111f18583d00cb0.html