输出多了一个换行符
程序代码: struct stuInfor *p=head;/*定义移动链表指针*/
system("cls");
printf("学号 姓名 性别 出生年月 班级 学校(系)\n");
while(p!=NULL)/*当学生记录不为空时*/
{
if(p->sex=='m')
{
printf("%-10ld%-10s 男 %-10s%-20s%-20s\n",p->stunum,p->name,p->birthday,p->stuclass,p->school);
}
else
{
printf("%-10ld%-10s 女 %-10s%-20s%-20s\n",p->stunum,p->name,p->birthday,p->stuclass,p->school);
}
p=p->next;
}
system("pause");
如图怎么性别为男的多出一个换行符
printf("%-10ld%-10s 男 %-10s%-20s%-20s\n",p->stunum,p->name,p->birthday,p->stuclass,p->school);
这一行去了换行符就可以,
哪位朋友给解释一下,小弟实在想不出来,万分感激,
还有输入字符时,系统中的缓冲字符只能用getchar()先取了吗?还有别的方式吗?谢谢了。









