can anyone please tell me how to create a normal file with the .dat extension because i want to save it as a binary file? thanks.
Printable View
can anyone please tell me how to create a normal file with the .dat extension because i want to save it as a binary file? thanks.
interestingly enough the extension name seems to indicate to the user more information than to the computer. .dat is the same as any other extension as far as I know. To store stuff as binary in a .txt file or a .dat file you can use ios::binary instead of the default output mode for ofstreams or fstreams which is text. Likewise you can store stuff as text in .dat file if you wish by using the default output mode of output streams.
The extension is irrelevant, just open a file for writing with .dat at the end:
Code:ofstream out ( "filename.dat", ios_base::binary );