这是示例文本文件内容:
5 //列
Id,Age,history,chemistry,biology //列名
100//数据行数
3245167,12,45,78,12 //用逗号分隔的数据行
30980424,10,26,38,98
等等..
这是我到目前为止的一般代码:
int main()
{
//prints out input from file.
ifstream myFile;
myFile.open("WRITE FILE NAME");
while(Myfile.good()) { // good means while there is smthg in the file keep reading it
// until you reach to the end.
string line;
getline(myFile, line, ','); //read text until comma, then stop and store in variable.
cout << line << endl;
}
return 0;
}