printf在if语句中赢了PRINT,特别是性别变量

时间:2017-10-08 19:03:06

标签: if-statement

下面我有一些代码要求用户性别进入网站,问题是我放置了printf()功能,在if语句中显示用户性别的消息,现在它不打印。

#include <stdio.h>
#include <stdlib.h>

int main()
{
    int age;
    char gender;

    printf("How old are you? \n");
    scanf_s(" %d", &age);

    printf("What is your gender \n");
    scanf_s(" %c", &gender);

    if (age >= 18) {
        printf("You may enter this website ");
    }

        if (gender == 'f') {
            printf("m'lady");
        }

        if (gender == 'm') {
            printf("dude");
        }

    if (age < 18){
        printf("Nothing to see here!");
    }

    system("pause");
    return 0;
}

0 个答案:

没有答案