m0_54226903 2022-07-26 16:57 采纳率: 0%
浏览 38

关于#c语言#的问题:#include <stdio.h>

D:\Devcppworkspace\ch04\试卷T13.c    [Warning] format '%c' expects argument of type 'int', but argument 2 has type 'char *' [-Wformat=]为什么会报了这个错%c不可以是char类型吗!
#include <stdio.h>
int main(){
    printf("%c","a");
    return 0;
} 

  • 写回答

4条回答 默认 最新

  • YoungGeeker 2022-07-26 17:08
    关注

    %c代表char的符号,%d是int,%f是float,%lf是double,%lld是long long,%s是字符串。
    C语言有严格的要求,单引号必定是char,只能容纳一个字符,双引号是字符串。
    应改为:printf("%c", 'a');
    如果对你有帮助,还请帮忙点个采纳,谢谢!

    评论

报告相同问题?

问题事件

  • 创建了问题 7月26日