1. char *buf = (char *)malloc(sizeof(char) * 11);  
  2. unsigned int offset;  
  3. offset = 0;  
  4. CString path = "d:\\1.txt";  
  5. CFile data;  
  6. CFileException mExcept;  
  7.  
  8. data.Open(path, CFile::typeBinary | CFile::modeRead, &mExcept);   
  9. cout << data.GetLength() << endl << endl;  
  10. data.Seek(offset, CFile::begin);  
  11. data.Read(buf, 10);  
  12. data.Close();  
  13. buf[10] = 0;  
  14. cout << buf << endl; 
  15.  
  16. data.Open(path, CFile::modeWrite | CFile::modeCreate);
     char *writeBuffer;
     writeBuffer = (char *)malloc(10);
     writeBuffer[0] = 'a';
     writeBuffer[1] = 'b';
     writeBuffer[2] = 'c';
     writeBuffer[3] = 'd';
     writeBuffer[4] = 0;
     writeBuffer[5] = 'e';
     data.Write(writeBuffer, 10);
     data.Close();