How do i open a binary file?

Write your question here.

1
2
3
4
5
6
7
8
9
10
11
fstream file("test.bin", ios::binary);

	if(file.is_open())
	{
		cout << "I am open." << endl;
	}
	else
	{
		cout << "re" << endl;
		return -1;
	}
Isn't it std::ifstream ? I haven't worked with files in ages...
 
fstream file("test.bin", ios::binary);

That's one correct way.
The other is:
 
ifstream file("test.bin", ios::binary);
"text" files are binary files, by the way. The binary functions can be way faster for handing "text" files, depending on the size and what is being done. I know you wanted the syntax but this is important to know if you ever have to handle huge text files like generated xml gone wrong.
Topic archived. No new replies allowed.