【发布时间】:2019-09-20 18:46:54
【问题描述】:
我正在尝试读取 2 行用户输入。对于第一个序列,如果我不输入任何内容并按回车键,程序将打印enter the second sequence,但不允许第二个scanf。基本上返回只是终止scanf,导致str1 和str2 都为空。
printf("enter the first sequence: ");
scanf("%[^\n]%*c", str1);
printf("enter the second sequence: ");
scanf("%[^\n]%*c", str2);
有什么办法可以解决这个问题吗?
【问题讨论】: