用以下方式建立qaz.txt文件
if(a.Open("d:\\qaz.txt",CFile::modeCreate|CFile::modeReadWrite
|CFile::typeText)==NULL)
{
MessageBox("建立“qaz.txt”文件失败","提示",MB_OK+MB_ICONWARNING);
return;
}
int a=23;
int b=3450;
int d=90;
CString my,j1,j2;
my.Format("%12d\n",a);
a.WriteString(my);
my.Format("%16d\n",b);
a.WriteString(my);
a.SeekTiBegin();
a.ReadString(j1);
a.ReadString(j2);
my.Format("%12d\n",d);
再用
a.WriteString(my);写入时,
系统提示
"在存取d:\qaz.txt时,磁盘已满"
拒绝写入,不解!!!!!!!!!!!!!!!!!!
if(a.Open("d:\\qaz.txt",CFile::modeCreate|CFile::modeReadWrite
|CFile::typeText)==NULL)
{
MessageBox("建立“qaz.txt”文件失败","提示",MB_OK+MB_ICONWARNING);
return;
}
int a=23;
int b=3450;
int d=90;
CString my,j1,j2;
my.Format("%12d\n",a);
a.WriteString(my);
my.Format("%16d\n",b);
a.WriteString(my);
a.SeekTiBegin();
a.ReadString(j1);
a.ReadString(j2);
my.Format("%12d\n",d);
再用
a.WriteString(my);写入时,
系统提示
"在存取d:\qaz.txt时,磁盘已满"
拒绝写入,不解!!!!!!!!!!!!!!!!!!
|CFile::typeText)
a为FILE类型的变量
int a=23;
a又为整型变量.
改个变量名啊
用以下方式建立qaz.txt文件
if(a.Open("d:\\qaz.txt",CFile::modeCreate|CFile::modeReadWrite
|CFile::typeText)==NULL)
{
MessageBox("建立“qaz.txt”文件失败","提示",MB_OK+MB_ICONWARNING);
return;
}
int f=23;
int b=3450;
int d=90;
CString my,j1,j2;
my.Format("%12d\n",f);
a.WriteString(my);
my.Format("%16d\n",b);
a.WriteString(my);
a.SeekTiBegin();
a.ReadString(j1);
a.ReadString(j2);
my.Format("%12d\n",d);
再用
a.WriteString(my);写入时,
系统提示
"在存取d:\qaz.txt时,磁盘已满"
拒绝写入,不解!!!!!!!!!!!!!!!!!!
CStdioFile file;
if(file.Open("d:\\qaz.txt",CFile::modeCreate|CFile::modeReadWrite
|CFile::typeText)==NULL)
{
MessageBox("建立“qaz.txt”文件失败","提示",MB_OK+MB_ICONWARNING);
return;
}
int a=23;
int b=3450;
int d=90;
CString my,j1,j2;
my.Format("%12d\n",a);
file.WriteString(my);
my.Format("%16d\n",b);
file.WriteString(my);
file.SeekToBegin(); file.ReadString(j1);
file.ReadString(j2);
my.Format("%12d\n",d);
file.SeekToEnd();//后加的
file.WriteString(my);估计是文件定位的问题,向文件中写内容的时候最好先定位一下!
将你的程序改为如下就对了:
CStdioFile a;
if(a.Open("d:\\qaz.txt",CFile::modeCreate|CFile::modeReadWrite
|CFile::typeText)==NULL)
{
MessageBox("建立“qaz.txt”文件失败","提示",MB_OK+MB_ICONWARNING);
return;
}int b=3450;
int d=90;
CString my,j1,j2;
my.Format("%12d\n",a);
a.WriteString(my);
a.SeekToEnd();//转到文件尾,进行写操作
my.Format("%16d\n",b);
a.WriteString(my);a.SeekToBegin();
a.ReadString(j1);
a.ReadString(j2);my.Format("%12d\n",d);
a.SeekToEnd();//转到文件尾,进行写操作
a.WriteString(my);这样就OK了!