// use C to write into file FILE *pFile=fopen("1.txt","w"); CString strTemp = "hello world!"; fwrite(strTemp,1,strTemp.GetLength(),pFile); fflush(pFile); fclose(pFile); // use C++ to write into file ofstream ofs("2.txt"); CString str = "Use C++.Hello World !"; ofs.write(str,str.GetLength()); ofs.flush(); ofs.close(); // use MFC to write into file CString str = "Use CFile,Hello World !"; CFile file("3.txt",CFile::modeCreate | CFile::modeWrite); file.Write(str,str.GetLength()); file.Flush(); file.Close();
三种向文件写入CString数据的方法
原创
©著作权归作者所有:来自51CTO博客作者koma0769的原创作品,请联系作者获取转载授权,否则将追究法律责任
上一篇:C++构造函数中的this指针
下一篇:POP3协议学习笔记
提问和评论都可以,用心的回复会被更多人看到
评论
发布评论
相关文章
-
Linux目录结构
在Linux中一切皆文件,这些文件按照一定的规则存放在不同的目录当中。为了能够快速找到文件及以后的操作的规范性,我们必须记清楚Linux的目录结构。
目录 云计算 Linux centos 自动化运维 -
局域网里加入新机
局域网里加入新机
局域网 加新机 -
获取程序当前目录(CString类型)
今天在群里看到一朋友发了这样一个函数,感觉很方面,收藏了
null 当前目录 string类 应用程序 字符串