Phone* creat()
{
ifstream file("Phone.txt");
if( !file )
{
for( int i = 0 ; i < 7; i++ )
cout< cout cout system("pause");
system("cls");
}
next=NULL;
Phone *pNew,*head,*q;
pNew=new Phone;
head=pNew;
q=head;
while(!file.eof())
{
string model,color;
int leftnum;
double price;
file>>model; //先读到内存里 再动态申请空间做成链表
file>>color;
file>>price;
file>>leftnum;
pNew->Model=model;
cout<Model;
pNew->Color=color;
cout<Color;
pNew->Price=price;
pNew->LeftNum=leftnum;
pNew->next=next;
Phone *pNew;
pNew=new Phone;
next=pNew;
}
file.close(); //打开了一定要用close()关闭
q=q->next;
while(q!=NULL)
{
cout<Model;
q=q->next;
}
return head;
}
Phone什么样的结构,看完代码后没办法调试,方便的话可以将其他代码给出,肉眼实在没有看问题在哪里。