CStdioFile Sample


Click here to change the theme.

The following is a sample use of CStdioFile:

CStdioFile Inputfile, Outputfile;
	CFileException FileExc;
	UINT nOpenFlags;
	CString s;
nOpenFlags = CFile::modeRead;
if (!Inputfile.Open("Console.txt", nOpenFlags, &FileExc)) {
	FileExc.ReportError();
	return;
	}
nOpenFlags = CFile::modeWrite | CFile::modeCreate;
if (!Outputfile.Open("Output.txt", nOpenFlags, &FileExc)) {
	FileExc.ReportError();
	return;
	}
while (Inputfile.ReadString(s))
	Outputfile.WriteString(s+'\n');
Inputfile.Close();
Outputfile.Close();