求助,搞不懂为啥这样的???
各位大侠,帮我看一下下面的gets(q->name)为什么在程序执行时被跳过了#include<stdio.h>
#include<stdlib.h>
//#include<conio.h>;
typedef struct studentsinformation
{
char name[20];
char munber[15];
float total;
struct studentsinformation *next;
}SDI;
//基本操作
SDI *initlist()
{
SDI *head=NULL,*p=NULL,*q=NULL;
int m=0,i=0;
p=(SDI *)malloc(sizeof(SDI));
head=p;
printf("输入要构建的结点个数\n");
scanf("%d",&m);
for(i=m;i>0;--i)
{
q=(SDI *)malloc(sizeof(SDI));
printf("第%d结点\n",m+1-i);
gets(q->name);printf("继续\n");//scanf("%f",&q->total);
gets(q->munber);
p->next=q; p=q;
}
return head;
}
void listdiaplay(SDI *head)
{
SDI *p=NULL;
p=head;//->next;
p=p->next;
while(p)
{
printf("%s %s %f\n",p->name,p->munber,p->total);
p=p->next;
}
}
void main()
{
SDI *sel1=NULL;
sel1=initlist();
printf("输出结点信息\n");
//getch();
listdiaplay(sel1);
}