所以我需要读取这两个csv文件,它们每个都有几列用空格分隔的文本。如何在不使用向量或数组的情况下将这些行拆分为标记?我是用c ++做的,无法找到任何帮助。
#include <iostream>
#include <fstream>
#include <string>
using namespace std;
int main() {
string line;
ifstream myfile ("elect12.csv");
if (myfile.is_open ())
{
cout << endl << "popular results " << endl;
while (getline (myfile, line))
{
cout << line << endl;
}
myfile.close();
}
else cout << "unable to open";
string line1;
ifstream myfile1 ("ev10.csv");
if (myfile1.is_open ())
{
cout << endl << "electoral votes per state" << endl;
while (getline (myfile1, line1))
{
cout << line1 << endl;
}
myfile1.close();
}
else cout << "unable to open";
return 0;
}