Advertisement

Opening Files for I/O in C++

Started by July 20, 2002 09:11 PM
2 comments, last by Jackysan 22 years, 3 months ago
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/
Advertisement

  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();  
Thanks alot! For some reason I was just having trouble finding out how to do that (I did find one other example, but because it was part of a whole entire program, it was quite confusing!)

This topic is closed to new replies.

Advertisement