<分区>
我的程序编译正常,但是当它调用 getinput() 函数时它从不提示输入。
编辑以显示更多代码,我添加了 fflush 但由于某种原因它仍然跳过它。
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
main(){
char mystring[] = "It's equal to it. ";
int k = 32;
int e;
printf("Enter a number: ");
scanf("%d",&e);
if(e == k){
printf("\n\n%s\n",mystring);
} else if(e < k){
printf("\n\n%d\n",e);
} else {
getinput();
}
exit(0);
}
int getinput(){
char gettext[64];
printf("Enter text here: ");
fflush(stdout);
fgets(gettext, 64, stdin);
printf("\n\nYou entered: %s\n\n",gettext);
return 0;
}