I'm trying to get my program to read a series of comma delimited values from a file into a vector. However, I am unsure how to actually go about doing this. I've posted my best guess below but it's really just a stab in the dark and I always receive a compiler error. Does anyone know the correct way to go about this?
Thanks!
Code:
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
using namespace std;
vector <string> v_input;
int main()
{
ofstream fout ("Insert File Path Here.txt");
fout << "4, 8, 15, 16, 23, 42";
fout.close();
ifstream getdata ("Insert File Path Here.txt");
while(!getdata.eof())
getline(getdata, v_input.push_back(), ','); //read comma separated values into a vector--problem line!
ifstream.close();
return 0;
)