int nLength=mFile.GetLength();
char *szBuffer=new char[nLength+1];
mFile.Read(szBuffer,nLength);
szBuffer[nLength]=0;
...
...
delete []szBuffer;

解决方案 »

  1.   

    你前面说的问题是因为sRead数组中没有NULL终止符,
    所以显示时,SetWindowText不知道显示到哪里为止。
      

  2.   

    哦,那么如何加上NULL终止符?手动加上'\0'吗?
      

  3.   

    上面不是已经给你加了szBuffer[nLength]=0;
      

  4.   

    CFile fp;
    CString mStr;
    if(!fp.Open(_T("c:\\user.txt"),CFile::modeRead))
       return ;
    if(fp.GetLength()!=0)
    {
        char* buf = mStr.GetBuffer(fp.GetLength());
        Fp.Read(buf,fp.GetLength());
        mStr.ReleaseBuffer();
    }
    mFile.Close();GetDlgItem(IDC_STATIC_MY)->SetWindowText(mStr);
      

  5.   

    多谢天堂鸟和shadow_nj的解答,不过现在太晚了,我决定睡觉觉了:),所以明天再继续向二位讨教,今天嘛,休息,休息