求助!!郁闷死了!error c2679
#include<iostream.h>
#include<fstream.h>
#include<string.h>
#include<iomanip.h>
struct student
{
char name[20];
float height;
student *next;
};
void main()
{
student a[100];
int i;
cout<<"请输入: 姓名 身高\n ";
for(i=0;i<100;i++)
{
cin>>a[i].name>>a[i].height;
a[i].next=NULL;
}
ofstream fout("student.txt");
if(!fout)
cout<<"文件打开失败!\n";
for(i=0;i<100;i++)
fout<<a[i].name<<" "<<a[i].height<<" "<<a[i].next<<endl;
fout.close();
ifstream fin("student.txt");
if(!fin)
{
cout<<"文件打开失败\n";
return;
}
student b[100];
i=0;
while(fin>>b[i].name>>b[i].height>>b[i].next)
i++;
student *head;
int j;
head=b;
for(i=1;i<100;i++)
{
if(head->height<b[i]->height)
{
b[i].next=head;
head=&b[j];
}
for(j=0;j<i;j++)
{
if(b[j].height<b[i].height)
{
b[i].next=b[j].next;
b[j].next=&b[i];
break;
}
b[j-1].next=&b[i];
}
}
cout<<setw(20)<<"姓名"<<setw(12)<<"身高"<<endl;
student *p;
p=head;
do
{
cout<<setw(20)<<p->name<<setw(12)<<p->height<<endl;
p=p->next;
}while(p!=NULL)
fin.close();
ifstream fin("student.txt");
if(!fin)
cout<<"文件打开失败\n";
char temp[20];
cout<<"请输入要查找的人姓名:";
cin>>temp;
student s;
while(fin>>s.name>>s.height>>s.next)
{
int k;
k=stricmp(s.name,temp);
if(k==0)
{
cout<<s.name<<s.height;
break;
}
if(k!=0)
cout<<"查无此人\n";
}
提示出错
--------------------Configuration: temp2 - Win32 Debug--------------------
Compiling...
a.cpp
D:\Cheung\阅读器\temp2\a.cpp(35) : error C2679: binary '>>' : no operator defined which takes a right-hand operand of type 'struct student *' (or there is no acceptable conversion)
D:\Cheung\阅读器\temp2\a.cpp(35) : fatal error C1903: unable to recover from previous error(s); stopping compilation
执行 cl.exe 时出错.
a.obj - 1 error(s), 0 warning(s)