CArchive 序列化,持久性

void CMfctempDlg::OnButton1() 
{
	// TODO: Add your control notification handler code here
	CFile file("1.txt",CFile::modeCreate|CFile::modeReadWrite );
	CArchive ar(&file,CArchive::store);
	int i=4;
	char ch='a';
	float f=1.3f;
	CString str("hello kugoo");
	ar<<i<<ch<<f<<str;
	
}

void CMfctempDlg::OnButton2() 
{
	// TODO: Add your control notification handler code here
	CFile file("1.txt",CFile::modeReadWrite );
	CArchive ar(&file,CArchive::load);
	int i;
	char ch;
	float f;
	CString str,yk;
	ar>>i>>ch>>f>>str;
	yk.Format("%i,%c,%f,%s",i,ch,f,str);
	MessageBox(yk);


}

你可能感兴趣的:(CArchive 序列化,持久性)