【发布时间】:2013-01-16 05:18:41
【问题描述】:
我的代码:
#include <iostream>
#include <fstream>
#include <string>
using namespace std;
.
.
.
void function() {
ofstream inputFile;
.
.
.
inputFile.getline (inputFile, inputField1, ",");
}
由于某种原因我无法弄清楚,使用 g++ 编译它会返回
error: ‘struct std::ofstream’ has no member named ‘getline’
另外,作为旁注,它也会产生错误
error: invalid conversion from ‘void*’ to ‘char**’
error: cannot convert ‘std::string’ to ‘size_t*’ for argument ‘2’ to ‘ssize_t getline(char**, size_t*, FILE*)’
但我认为我的参数是错误的。
谁能帮忙解释一下?
【问题讨论】:
-
似乎有多个问题:
ofstream用于输入,您似乎正试图读入std::string(因此istream中的成员函数getline将不起作用要么...)谷歌getline并找到需要std::string的免费函数