Why doesn't the following code create a new file
Code:int main() { std::fstream file; file.open("something.bin",std::ios::binary|std::ios::in|std::ios::out); if(!outfile) std::cout<< "unable to open\n"; }
Why doesn't the following code create a new file
Code:int main() { std::fstream file; file.open("something.bin",std::ios::binary|std::ios::in|std::ios::out); if(!outfile) std::cout<< "unable to open\n"; }
The following code:Will open a file if it exists, it will fail to open the file if it does not exist. You will need to use one of the other std::ios flags to get the file to be created, app, or trunc, depending on how whether you want to keep the data if the file exists, or erase the data.Code:file.open("something.bin",std::ios::binary|std::ios::in|std::ios::out);
Jim