Hi! i am writing a program in which i am reading a text file named "studentinfo". I have made a notepad file as "studentinfo" and then wrote a program to read this file. but there is an error occuring : " invalid operand of types 'char[20]'and '<unknown type>' to binary 'operator<<' ".
the above error is occuring in line no 19. but i couldn't understand this error.Please explain me.
The code of my program is following:
#include<iostream.h>
#include<fstream.h>
main()
{
char name[30];
char rollno[20];
char program[20];
ifstream myfile; // handle to file.
char inputfilename[]="studentinfo";
myfile.open(inputfilename);
if(!myfile)
{
cout<<"file"<<inputfilename<<"cant open";
exit(1);
}
while(!myfile.eof())
{
myfile>>name>>rollno>>program ;
cout<<name<<"\t"<<rollno<<"\t"<program<<endl; // this is line no 19.
}
myfile.close();
system("pause");
}