MFC关于使用CArchive流输入产生的问题

今日用CArchive练习流输入,不料输出结果有差异,未查明原因,特此记录

void CTxtView::OnFileWrite()
{
 // TODO: Add your command handler code here
 CFile file("c:\\1.txt",CFile::modeCreate||CFile::modeWrite);
 CArchive ar(&file,CArchive::store);
 CString str="123";
 ar<<str;
 ar.Flush();
 //file.Write("123",3);
 ar.Close();
 file.Close();
}

文本显示为 "123"  为何前面多了个未知字符,而用file.Write("123",3);则不会产生

原文地址:https://www.cnblogs.com/yuqilihualuo/p/3002088.html