即使条件语句为假,代码也不会停止

时间:2019-06-16 09:33:03

标签: c

我正在学习C的同时,我的生活也越来越困难。

我正在尝试构建一个工具,如果在scanf中提供2个以上的arg会破坏该工具,但我无法这样做。

这是我的代码。

#include <stdio.h>

int main()
{
    printf("Let me scan some data!!\n");
    char test[10];
    char test1[10];
    while (scanf("%s%s[^\n]", test, test1) == 2)
    {
        printf("Data is as follows: %s and followed by %s \n", test, test1);

    }

    return 0;
}

请帮助我,我尝试了一些反复尝试但失败了。

0 个答案:

没有答案