首页 > 解决方案 > scanf() 被跳过并在 C++ 中嵌套代码

问题描述

我试图让 2 个单词进行比较,无论它们是否相同,但第 14 行的 scanf() 不起作用,代码直接打印“False”

#include <string.h>
#include <stdio.h>

int main()
{
int w1, w2;                     //word 1, word 2

{

printf("What is the first word?");
scanf("%%", &w1);

printf("What is the second word?");
scanf("%%", &w2);                        <--------line 14

{
    if
    (w1 == w2) {
    printf("True");
    }
    else {
        printf("False");
    }
}

}
}

标签: c

解决方案


推荐阅读