c语言和C++语言中打开并读取文件方法的对比介绍

c语言中文件I/O:
FILE* pfile = fopen(“c:\1.txt”, ab );
fwrite();
fread();
fprintf();
fclose(pfile);

null

c++语言中文件I/O:
std::string chFileName = “c:\1.txt”;
ifstream fin( chFileName.c_str() );
std::string aLine;
while ( getline( fin, aLine ) )
{
//do what you want to do…
}
fin.close();

© 版权声明
THE END
喜欢就支持一下吧
点赞0 分享
评论 抢沙发
头像
欢迎您留下宝贵的见解!
提交
头像

昵称

取消
昵称表情代码图片

    暂无评论内容