C语言简单问题,在线等,急用加分

Student*Delete_a_Record(Student*head){Charname[100][20];charfoobar,alter;inti;printf(... Student *Delete_a_Record(Student *head)
{ Char name[100][20];
char foobar,alter;
int i;

printf("Delete a record?...Y/N\n");
scanf("%c",&foobar);

c3: if(foobar=='y'||foobar=='Y')
{ printf("Please enter name list\n");
for(i=0;;i++)
{ gets(name[i]);

Delete(head,name[i]);
else if(foobar=='n'||foobar=='N')
{ printf("Delete teminated\n"); goto End; }
else goto c3;
End: return head;
}
我写了这样一个函数,经证明,中间调用的delete函数没有问题。
问题在于:在c3处,输入foobar之后,系统显示 please input namelist,但是在这里没有停留,直接显示Continue?...Y/N 。在当我再次用Y确认后恢复正常,其中又一次录入肯定是不对的,求高人解答,致谢。
c3: foobar=getchar();

if(foobar=='y'||foobar=='Y')
{ printf("please input namelist\n");
for(i=0;;i++)
{ gets(name[i]);

printf("Continue?...Y/N\n");
c4: alter=getchar(); getchar();
if(alter=='y'||alter=='Y') continue;
else if(alter=='n'||alter=='N') break;
else goto c4; }

}不好意思,上面的程序少了一部分
展开
 我来答
L_o_o_n_i_e
2011-05-11 · TA获得超过4.2万个赞
知道大有可为答主
回答量:8507
采纳率:38%
帮助的人:6024万
展开全部
scanf("%c",&foobar); 后加 fflush(stdin); 清除缓冲区里的enter 键。
foobar=getchar(); 后加 fflush(stdin); 清除缓冲区里的enter 键。
追问
那么头文件需要追加什么吗?
追答
stdio.h  stdlib.h
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式