【发布时间】:2016-10-30 01:49:09
【问题描述】:
void clrKyb(void)
{
char c[30];
scanf("%s",c);
for(int i = 0; i < 30; i++){
if(c[i] == '\n'){
i = 30;
}
}
}
void pauses(void)
{
printf("Press <ENTER> to continue:");
clrKyb();
}
您好,我卡在“暂停”功能上。按 ENTER 继续不起作用?
【问题讨论】:
-
%s尝试读取一个单词。如果只是按回车,没有字,所以会一直等待。 -
scanf不安全。请改用scanf_s。 msdn.microsoft.com/en-us/library/w40768et.aspx -
@Dai:这不是微软特有的吗?
-
@KeithThompson 如果它们是,那么它们不再是它们了:它们在 C11 中被标准化:en.cppreference.com/w/c/io/fscanf
标签: c