problem with fstream::open()

Eh i tried to open a file with the standard code:
1
2
3
4
5
6
7
	fstream outf;
	outf.open ("Height.txt", ifstream::in | ifstream::trunc);
	
	if(!outf) {
		cout << "couldn't open outf\n";
		return 2;
	}


and i have no idea why, it ALWAYS prints "couldn't open outf" and exits...

and i check in outf.is_open() under "watch" in debug mode, it says member function doesn't exist.
Last edited on
It doesn't make any sense to open a file for input (read from the file) and truncate it (delete all it's content).
... OH i tot "in" was for writing IN! OMG
hahhaha thanks yo!

its working fine now. changed the in to out
Last edited on
It might be a good idea to use ofstream ad ifstream, rather than a generalized fstream.
Topic archived. No new replies allowed.