一开始我要存储数据到一个txt文件,等到要用时再取出来
比如:int a=1;
CFile myfile;
myfile.Open("data.txt",CFile::modeCreate|CFile::modeReadWrite,NULL);
myfile.Write(&a,2);
myfile.Close();
int b;
myfile.Open("data.txt",CFile::modeRead,NULL);
myfile.Read(&b,2);
myfile.Close(); //然后比较a跟b的值
if(a==b)
AfxMessageBox("equal")不知道上面的程序对于读写数据是否正确,还望大家多多指点//bow
比如:int a=1;
CFile myfile;
myfile.Open("data.txt",CFile::modeCreate|CFile::modeReadWrite,NULL);
myfile.Write(&a,2);
myfile.Close();
int b;
myfile.Open("data.txt",CFile::modeRead,NULL);
myfile.Read(&b,2);
myfile.Close(); //然后比较a跟b的值
if(a==b)
AfxMessageBox("equal")不知道上面的程序对于读写数据是否正确,还望大家多多指点//bow
myfile.Read也是一样的道理,因为在不同系统下int的大小是不同的