1. // use C to write into file   
  2. FILE        *pFile=fopen("1.txt","w");  
  3. CString     strTemp = "hello world!";  
  4. fwrite(strTemp,1,strTemp.GetLength(),pFile);  
  5. fflush(pFile);  
  6. fclose(pFile);  
  7.   
  8. // use C++ to write into file   
  9. ofstream    ofs("2.txt");  
  10. CString     str = "Use C++.Hello World !";  
  11. ofs.write(str,str.GetLength());  
  12. ofs.flush();  
  13. ofs.close();  
  14.   
  15. // use MFC to write into file   
  16. CString     str = "Use CFile,Hello World !";  
  17. CFile       file("3.txt",CFile::modeCreate | CFile::modeWrite);  
  18. file.Write(str,str.GetLength());  
  19. file.Flush();  
  20. file.Close();  

相关文章:

  • 2021-12-10
  • 2022-12-23
  • 2022-01-08
  • 2021-04-03
  • 2022-12-23
  • 2022-12-23
  • 2021-12-10
  • 2022-12-23
猜你喜欢
  • 2021-06-21
  • 2022-12-23
  • 2022-12-23
  • 2021-12-04
  • 2021-08-28
  • 2022-12-23
相关资源
相似解决方案