c++ - 在myfile中未在此范围内声明

标签 c++ csv compiler-errors

嘿,所以我用c++编写了一个以csv格式打开数据的代码,它显示了在此范围内未声明错误myFile.open
代码:

#include <fstream>
#include <string>

using namespace std;

int main() {
    ifstream myFile;
    myFile.open (SBIN.csv);
    while (myFile.good()) {
        string line;
        getline(myFile, line, ',');
        cout<< line<<endl;
    }
    
}```

最佳答案

替换此行:

myFile.open (SBIN.csv);
myFile.open ("SBIN.csv");
open()接受字符串,并且您尚未声明名为SBINcsv的变量。

关于c++ - 在myfile中未在此范围内声明,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64087906/

相关文章:

c++ - 尝试使用 cmake 编译代码时 undefined reference

c++ - Eclipse CDT C++ 枚举 "could not be resolved"

c# - 奇怪的属性错误

arrays - 比较两个对象数组时出现难以理解的 Swift 编译器错误

shell - 如何在 fish shell 中使用compile_commands.json?

c++ - Eigen 类取矩阵每一行的平均值(计算列 vector 的质心)

c++ - 需要了解良好的 C++ 反射 API(用于 RuntimeType Identification -RTTI 和运行时调用)

c# - 表导出到 CSV 不保留 SQLite 日期格式

mysql - 发送 csv 或填充数据库?

vba - 重新打开时 CSV 中的前导零