#includeCFile myfile; //opens the file "example.txt" for writing myfile.OpenForWrite("example.txt");
#includeIn this example, we create a CFile object named "myfile" and open the file "data.dat" for writing in binary mode using the "OpenForWrite" function. The "modeCreate" flag creates the file if it does not exist and "modeWrite" flag sets the file to write mode. The "typeBinary" flag sets the file to binary mode. Package library: xfile.h.CFile myfile; //opens the file "data.dat" for writing in binary mode myfile.OpenForWrite("data.dat", CFile::modeCreate | CFile::modeWrite | CFile::typeBinary);