fstream 读写心得.docxVIP

  • 12
  • 0
  • 约7.11千字
  • 约 6页
  • 2017-08-05 发布于河南
  • 举报
fstream 读写心得

fstream 读写心得首先读写中文应为wifstream 和 ofstream。下面的我也不知道为什么?但是可以正常使用、#includeiostream #includeiomanip #includefstreamusingnamespacestd;intmain(){ setlocale(LC_ALL,chs);//设置wcout,能正常显示中文wchar_tch ,str[]={ L一二三四五六七八};wofstreamoutfile(letter.txt);outfile.imbue(std::locale(chs)); //可以正常写入if (!outfile){cout 不能建立文件!endl;exit(1);}outfile.write(str,wcslen(str));outfile.flush();outfile.close();localeloc(chs);wifstreaminfile;infile.imbue(loc);//可以正常读出infile.open(letter.txt);if (!infile){cout 不能打开文件!endl;exit(1);}infile.seekg(0,ios::beg);infile.read(ch,1);wcout L第一个字符是: ch endl;infi

文档评论(0)

1亿VIP精品文档

相关文档