Create Binary I/O file

I've been looking into accessing, writing, and editing .dat files. How do you check to see if a file exists, and if not then create the file?

1
2
fstream bIO; // Create stream object
bIO.open("binary.dat", ios::out | ios::binary);


This opens a file that already exists..how do you create one if it doesn't exist?
A file stream opened for output should create the file if it doesn't exist
Yeah tested it out and it works. If I input an array of ints into the .dat file by using ios::app...how do I read the size of the entire file and not just what I added?
There isn't a good way to determine file size using standard C++ but tellp ( or tellg ) should work if you are at the end of the file
Topic archived. No new replies allowed.