WARNING : The problem stated here is extremely noobish!
I have created a blank CPP project in visual studio. It should create a file named pt_data.bin at D:\ but the file is found nowhere. Even when I remove the path, its not in the project folder.
An fstream will not create a file if it doesn't exist when using the default open modes. If you want to create the file if it doesn't exist you will need to use the ios::app mode when opening the file.
You should always check if you successfully open the file before trying to do anything with the file.
1 2 3 4 5 6 7 8
...
fstream fout("D:\\pt_data.bin", ios::app | ios::binary);
if(!fout)
{
cerr << "Couldn't open the file for writing." ;
return 1;
}
...