向结构体数组输入数据一直崩溃
程序代码:
#include<stdio.h> struct per{ char fth_name[15]; char mid_name[15]; char lst_name[15]; }; struct info{ int num; struct per name; }; void show(const struct info *); int main(void) { struct info peo_info[5]; int n=0; puts("please the infomation about the first people"); while(n<5) { puts("enter the first name:"); gets(peo_info[n].name.fth_name); puts("enter the middle name(if you don't have a mid name,enter an empty line at the begin of the line)"); gets(peo_info[n].name.mid_name); puts("enter the last name"); gets(peo_info[n].name.lst_name); puts("please the infomation about the next people"); while(getchar()!='\n') { continue; } scanf("%d",peo_info[n].num); n++; } }
声明了一个包含结构体的结构体,然后建立了结构体数组,然后输入完第一组数据就崩了。
请问是哪里的原因