次の形式のファイルがあります: FirstName,MiddleName,LastName,Major,City,State,GPA
ファイルを読み込んで、コンマなしでデータを画面に出力しようとしています。これは私がこれまでに持っているものですが、GPAのみを出力します:
#include <fstream>
#include <iostream>
#include <string>
#include <sstream>
using namespace std;
int main(){
string fileline;
string word;
ifstream studentData;
studentData.open("studentData.csv");
while(studentData){
getline(studentData,fileline);
istringstream ss(fileline);
while(getline(ss, word,','));{
cout << word << '\n';
}
}
return(0);
}