Opening Files for I/O in C++
I posted this just after a question about QBasic and VBasic. I was also wondering, just how do I open files for reading and writing in C++? I really can''t do anything too interesting if my programs can''t use other files and libraries (although I do know how to use include files, but that darn define# statement just pisses me off :-) !) How do I do it? Thanks.
http://www.cplusplus.com/ref/iostream/fstream/
http://www.cplusplus.com/ref/cstdio/
http://www.cplusplus.com/ref/cstdio/
ifstream fin; // input streamofstream fout; // output stream fin.open("input.txt"); // open inputif(fin.fail()){ cout << "ERROR: Could not find input.txt!\n"; return 1; } while (!fin.eof()) // read input file{...}fin.close();
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement