Create Binary I/O file
Feb 23, 2011 at 7:29pm UTC
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?
Feb 23, 2011 at 7:56pm UTC
A file stream opened for output should create the file if it doesn't exist
Feb 23, 2011 at 9:13pm UTC
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?
Feb 24, 2011 at 10:35am UTC
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.