您的位置:首页 > 其它

三种向文件写入CString数据的方法

2009-09-21 19:19 281 查看
// use C to write into file
FILE		*pFile=fopen("1.txt","w");
CString		strTemp = "hello world!";
fwrite(strTemp,1,strTemp.GetLength(),pFile);
fflush(pFile);
fclose(pFile);

// use C++ to write into file
ofstream	ofs("2.txt");
CString		str = "Use C++.Hello World !";
ofs.write(str,str.GetLength());
ofs.flush();
ofs.close();

// use MFC to write into file
CString		str = "Use CFile,Hello World !";
CFile		file("3.txt",CFile::modeCreate | CFile::modeWrite);
file.Write(str,str.GetLength());
file.Flush();
file.Close();
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  mfc c