So this is giving me my desired output except that the last line print twice (minus the name).It is repeating data at the end that is not present in the small little excel sheet. Is there anything obvious in my code, i am guessing my While loop, that would be causing it to do this? Thank you!
#include <iostream>
#include <fstream>
#include <iomanip>
#include <string>
using namespace std;
int main() {
// declare variables
ifstream inFile;
string name, age, dec, ch, extra;
// open file
inFile.open("C:/Users/Joe/Downloads/input.csv");
//create loop that stops when entire file is read
while (!inFile.eof()) {
//collects all data up to a ',' and then stores that data in the respective variable
getline(inFile, name, '\,');
getline(inFile, age, '\,');
getline(inFile, dec, '\,');
getline(inFile, ch, '\,');
getline(inFile, extra);
cout << left;
cout << setw(8) << name
<< setw(8) << age
<< setw(10) << dec
<< setw(5) << ch
<< setw(5) << extra
<< endl;
}
// closes the file
inFile.close();
//pause and exit
getchar();
getchar();
return 0;
}