首页 > 解决方案 > getline() 在尝试读取重读字母后停止工作

问题描述

我有一个 .csv 文件,其中包含以下内容:

leería toda la linea,
si pudiera,

我尝试使用以下代码阅读它:

#include <iostream>
#include <fstream>
#include <string>



int main(){
    std::wstring wstr;
    std::wifstream FILE("data.csv");

    if(FILE){
        getline(FILE, wstr, L',');
        std::wcout << wstr << std::endl;
        FILE.close();
    } else {
        std::cout << "The file failed to open";
    }
    FILE.close();
    return 0;
}

输出是:

leer

到达“í”后似乎停止阅读。为什么我的代码不起作用?

标签: c++stringfile

解决方案


推荐阅读