没得错误,但是运行就不得行,请帮哈忙

来源:百度知道 编辑:UC知道 时间:2024/05/27 18:49:16
#include<iostream.h>
#include<iomanip.h>
#include<malloc.h>
#define LEN sizeof(struct student)
struct student
{
char name[10];
int xuehao[15];
int roomnumber[15];

struct student *next;
};

/*void meum()

{
cout<<"***************欢迎进入学生宿舍管理查询软件系统界面*********"<<endl;
cout<<setw(6)<<"1.排序"<<setw(7)<<"2.查询"<<endl;
}*/
struct student *creat(void) //创建链表
{
struct student *head,*p1,*p2;
int n=0;
p1=p2=(struct student*)malloc(LEN);
cin>>p1->name[10];
cin>>p1->xuehao[15];
cin>>p1->roomnumber[15];
head=NULL;
while(p1->name!=0)
{ n=n+1;
if(n==1)head=p1;
else
{p2->next=p1;
p2=p1;}
p1=(struct student*)malloc(LEN);

cin>>p1->name[10];
cin>>p1-

cin>>..这种形式是不能对整个数组进行逐一元素赋值的,如果要对char数组进行赋值,就要用cin.getline()函数,如果要对其它类型的数组赋值,就要用循环逐一进行。
cin>>xx[15];这种格式是不正确的。
修改结构体的两个成员的类型是为了在不影响程序运行效果的前提下减少代码数量,如果xuehao[15]和roomnumber[15]用了int类型,就不能用cin.getline()函数,而必须用循环,这样代码的数量就添加了。

//---------------------------------------------------------------------------

#include<iostream.h>
#include<iomanip.h>
#include<malloc.h>
#define LEN sizeof(struct student)
struct student
{
char name[10];
char xuehao[15]; /*注意这里*/
char roomnumber[15]; /*注意这里*/

struct student *next;
};

/*void meum()

{
cout<<"***************欢迎进入学生宿舍管理查询软件系统界面*********"<<endl;
cout<<setw(6)<<"1.排序"<<setw(7)<<"2.查询"<<endl;
}*/
struct student *creat(void) //创建链表
{
struct student *head,*p1,*p2;
int n=0;
p1=p2=(struct studen