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 继续不起作用?
只需使用 getchar(),它返回从 stdin 读取的第一个字符并等待 ENTER。
#include <stdio.h>
void clrKyb(void) {
while ((c = getchar()) != '\n' && c != EOF) {};
}
void pause(void) {
printf("Press <ENTER> to continue.");
clrKyb();
}