CString strText;
CString szLine; //存储行字符串
CStdioFile file;
file.Open("ts.txt",CFile::modeRead);//打开文件
//逐行读取字符串
while( file.ReadString( szLine ) )
{
strText += szLine;
}
MessageBox(strText);
//关闭文件
file.Close();
文件操作要包含:#include "fstream.h"
代码:
char str[80];
ifstream in("in.txt");
in.getline(str,80);
CString str1(str)
in.getline(str,80);
CString str2=str;
in>>str3
ofstream out("out.txt");
out<