代码搬运工@@ 2018-01-18 06:00 采纳率: 50%
浏览 5283
已采纳

vs2015 C++读取文件输出内容,总是显示乱码

#include
#include
#include
#include
#include
using namespace std;
int main()
{
ifstream sfile("1.txt");
if (!sfile)
{
cerr << "无法打开文件" << endl;
system("pause");
return -1;
}

string line;
vector<string> word;
while (getline(sfile, line))
{
    word.push_back(line);
}
sfile.close();
//for (auto it :word)
vector<string>::const_iterator it = word.begin();
while (it != word.end())
{
    istringstream line_str(*it);
    string words;
    while (line_str >> words)
        cout << words << " ";
    cout << endl;
    ++it;
}
system("pause");
return 0;

}
图片说明

  • 写回答

15条回答 默认 最新

  • 浩子乄 2018-01-18 06:06
    关注

    你将文件编码修改一下

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(14条)

报告相同问题?

悬赏问题

  • ¥15 如何在3D高斯飞溅的渲染的场景中获得一个可控的旋转物体
  • ¥88 实在没有想法,需要个思路
  • ¥15 MATLAB报错输入参数太多
  • ¥15 python中合并修改日期相同的CSV文件并按照修改日期的名字命名文件
  • ¥15 有赏,i卡绘世画不出
  • ¥15 如何用stata画出文献中常见的安慰剂检验图
  • ¥15 c语言链表结构体数据插入
  • ¥40 使用MATLAB解答线性代数问题
  • ¥15 COCOS的问题COCOS的问题
  • ¥15 FPGA-SRIO初始化失败