C程序,scanf为char,然后重新打印?

时间:2013-09-25 18:43:30

标签: c scanf getchar getch

#include <stdio.h>
int main(void)
{
    char fever, cough;

    printf("Are you running a fever? (y/n)\n");
    scanf("%c",&fever);

    printf("Do you have a runny nose/cough? (y/n)\n");
    scanf(" %c",&cough);

    printf("Please verify the folling information.\nFever: %c \nRunny nose/cough: %c \n,fever,cough");
return 0;
}

当我跑步时,我得到: 12:2警告:格式'%c'需要匹配的'int'参数[-Wformat]

我需要改变什么?我知道一切都是系统正确的,我只需要使用别的东西,我找不到任何能够明确解决我问题的东西!

谢谢你们。

4 个答案:

答案 0 :(得分:1)

printf("Please verify the folling information.\nFever: %c \nRunny nose/cough: %c \n,fever,cough");    

以上陈述系统性不正确。错位"

MODIFY喜欢这个

printf("Please verify the folling information.\n Fever: %c \nRunny nose/cough: %c \n ",fever,cough);   

答案 1 :(得分:0)

非常贴近报价。改变,发烧,咳嗽&#34;发烧,咳嗽

答案 2 :(得分:0)

您没有正确放置结尾"引用

printf("Please verify the folling information.\nFever: %c \nRunny nose/cough: %c   \n",fever,cough);
                                                                                     ^ Close your quote here

答案 3 :(得分:0)

您没有将发烧或咳嗽参数传递给printf。只需添加发烧和咳嗽作为printf功能的参数。引用应该在文本之后但在变量之前。