#include <fstream> //really needed
#include <string> //really needed
#include <vector> //really needed
#include <sstream> //string to sstream, line 18
#include <iostream> //cout, line 24
int main()
{
std::ifstream file("teams.csv");
std::vector<std::string> filecontent;
std::string rdstr;
while(std::getline(file,rdstr,'\n')) //while there still data, until '\n'
if(!rdstr.empty()) filecontent.push_back(rdstr); //if it wasn't an '\n', add to the array
//Use the info written in filecontent as you want. Now, one new use of getline:
std::vector<std::vector<std::string>> file_by_comma;
for(auto a : filecontent) //c++11
{
std::vector<std::string> temp;
std::istringstream c (a);
while(std::getline(c , rdstr, ',')) //get all words separeted by ','
if(!rdstr.empty()) temp.push_back(rdstr);
file_by_comma.push_back(temp);
}
for(auto a : file_by_comma)
{
for(auto b : a) std::cout << b << '\t';
std::cout << std::endl;
}
}
/*try it with your file and see what happens, but remember: C++ 2011!*/