我正在尝试读取csv文件并将其写入数组。getline中出现错误。错误为:没有重载函数“getline”的示例与参数列表匹配.出什么问题了?
#include <iostream>
#include <fstream>
#include <string>
using namespace std;
int main()
{
ifstream Input("M.A.csv");
int index = 0;
const int Num = 57;
int shift_counter = 0;
char Data[Num][6];
if (Input.is_open()) {
cout << '\n' << '\t' << "Anslyzing file..." << endl << '\n';
while (Input) {
getline(Input, Data[index]);
cout << Data[index][2];
cout << ++index << endl;
if (++index == Num) {
index = 0;
shift_counter++;
cout << '\n' << '\t' << "*** shift_counter is :" << shift_counter << '\n' << '\t';
}//if (++index == Num)
}//while (Input)
/*for (int i = 1,j=1; i <= Num ,j<=6 ; i++, j++) {
Data[i][j]=
}*/
}//if (Input.is_open())
else {
cout << '\n' << '\t' << "No file has been opened" << endl << '\n';
}//else
system("pause");
return 0;
}
char类型与getline无关,那么为什么我不能getline?
1条答案
按热度按时间eagi6jfj1#
function getline()要求第二个参数为
std::string
,但您提供了一个char
数组。没有重载具有这些类型的示例。