C编程如果语句不起作用

0 c if-statement

我的if语句不起作用,我不知道为什么.有人可以指出我的错误,谢谢.这只是我为练习而做的一个愚蠢的程序,我在这里设置了很多变量.

#include <stdio.h>

main()
{

    //This is a program that determines what circle of hell the user will be put in.  Inspired by Dante's Divine Comedy
    char firstQuestion;

    float total = 0;

    printf("ABANDON ALL HOPE, YOU WHO ENTER HERE\n\n");
    printf("Welcome to the gate of hell. I am going to ask you a series of questions and you will answer them truthfully.\n\n\n");

    printf("I would first like to ask you, do you believe you are a good person?(Y or N)\n");
    scanf_s(" %c", &firstQuestion);
    if (firstQuestion == 'Y'){
        printf("We will see about that.\n");
        total = total + 10;
    }
    else if (firstQuestion == 'N'){
    printf("I'm not surprised.\n");
}
    return 0;

}
Run Code Online (Sandbox Code Playgroud)

Nis*_*ant 5

scanf_s()不是scanf()的替代品.输入参数是字符或字符串时,应包含缓冲区大小.

scanf_s(" %c", &firstQuestion,1);  //For single character

char s[10];

scanf_s("%9s", s, 10);    //For reading a string
Run Code Online (Sandbox Code Playgroud)