【发布时间】:2021-10-22 00:32:04
【问题描述】:
#include <stdio.h>
#include<string.h>
int main() {
// Write C code here
char word[20];
char cat[20];
printf("Enter the thing:");
scanf("%[^,]",word);
scanf("%[^,]",cat);
printf("%s",word);
printf("%s",cat);
return 0;
}
这是我的代码,它打印出 word 的值,而不是 cat 的值?
【问题讨论】:
-
顺便说一句,我不会称其为重复,但有一个相关的问题,该问题围绕
%[^的具体问题展开:How format specifiers works with scanf in loop in C?