文件运行结果出错
代码如下(练习文件读写)
#include <afx.h>
#include <iostream.h>
#include <conio.h>
void main()
{
CFile file("test.txt",CFile::modeCreate|CFile::modeReadWrite);
file.Write("测试",strlen("测试"));
char *aa;
DWORD bb;
bb=file.GetLength();
aa=new char[bb+1];
aa[bb]=0;
file.Read(aa,bb);
file.Close();
cout<<aa<<endl;
getch();
}
编译连接成功 得test.exe 运行后 目录下生成test.txt内容为“测试” 可是test.exe里面(cmd)显示的是“屯屯”不是“测试”
谁知道哪里出错了?