Hi, I decided to write a prog that requires me to open an external data file and read and manipulate each line of the file one at a time. I have never taken any classes so I dont have a book, just read a few tutorials online. I cant find seem to find the syntax I need though for this problem. I actually have the data file open, using a tut that used this syntax:
but It doesnt go into any further detail about how to go about reading line by line. Like for instance if the file has a list of names that has to be changed then placed back in the file or output.Code:int main () { string line; ifstream myfile ("myfile.txt"); if (myfile.is_open()) { while (! myfile.eof() ) { cout << line << endl; } } else cout << "Unable to open file"; return 0;
Any suggestions? Help is greatly appreciated.



LinkBack URL
About LinkBacks


