file reading
Hello !
i can read the file in C++ but don't know how to read it between two points
to read the whole file
1 2 3 4 5 6 7 8 9
|
string STRING;
ifstream infile;
infile.open("file");
while(!infile.eof())
{
getline(infile,STRING);
cout<<STRING <<endl;
}
|
what will be logic to stop reading the file when program finds -1 character?
i suppose i need to do like
1 2 3 4
|
while(!infile.eof() || STRING !="-1"){
getline(infile,STRING);
cout<<STRING<<endl;
}
|
this one works
1 2 3 4
|
while(!infile.eof() && STRING.compare("-1")){
getline(infile,STRING);
cout<<STRING<<endl;
}
|
but it is not working can anyone fix it?
Thanks in advance.
Last edited on
Topic archived. No new replies allowed.