用以下方式建立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时,磁盘已满"
拒绝写入,不解!!!!!!!!!!!!!!!!!!

解决方案 »

  1.   

    如果你的程序没有帖错的话,看看你的变量:a.Open("d:\\qaz.txt",CFile::modeCreate|CFile::modeReadWrite
                            |CFile::typeText)
    a为FILE类型的变量
    int a=23;
    a又为整型变量.
    改个变量名啊
      

  2.   

    SORRY 文件a.Open("......应为W.Open("......
      

  3.   


    用以下方式建立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时,磁盘已满"
    拒绝写入,不解!!!!!!!!!!!!!!!!!!
      

  4.   

    我已经用MessageBox()检验了,j1 j2写入和读出都对
      

  5.   

    首先你的变量重复定义了,我修改了一下你的代码,如下
    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);估计是文件定位的问题,向文件中写内容的时候最好先定位一下!
      

  6.   

    因为你的程序没有定位,
    将你的程序改为如下就对了:
       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了!