用cfile类,
读入data.dat
把第八个字节ascii码+1后用AfxMessageBox()输出。
cfile类不会用啊,msdn看得稀里糊涂。
要是能看到一个例子就好了?

解决方案 »

  1.   

    CFile file;
    char str[8];
    if(!file.Open(data.dat,CFile::modeRead | CFile::typeBinary))
    {
      file.Open(str,sizeof(str));
      file.Close();
    }
    else
      MessageBox("Can not open file!")CString strr = str;
    用strr.Find()找出第八个就可以了!
      

  2.   

    void CXm9Dlg::OnButton1() 
    { CFile f1;
    unsigned int ch=0;CString str;f1.Open("C:\\data.dat",CFile::modeRead|CFile::typeBinary);void *p=GlobalAlloc(GMEM_ZEROINIT,1);
    if(p==NULL) 
     AfxMessageBox(_T("Failed to Allocat Memory")); while(f1.GetPosition()!=f1.GetLength())
    {  
    for(int x=0; x<8; x++)
    f1.Read(p,1);
    }ch=*((int *)p);
    ch++;str.Format("%d",ch);
    AfxMessageBox(str);
    f1.Close();
    GlobalFree(p);
    }