this is my code below, the output is numbers relating to a grade. I want to be able to make each line of the string a variable such as int grade1 and so on, so that I can display certain variables and not the whole string for example cout << grade1 << grade2 << endl;
using namespace std;
int main()
{
string line;
ifstream myfile("Data.csv"); //opening the CVS file
if (myfile.is_open())
{
while (getline(myfile, line)) //used to read each line of the file
{
string str(line); //making the file a string
char chars[] = ",abcdefghijklmnopqrstuvwxyzN;:/"; //Characters to be removed
for (unsigned int i = 0; i < strlen(chars); ++i)
{
str.erase(std::remove(str.begin(), str.end(), chars[i]), str.end());
}
str.replace(0, 9, " ");
cout << str << endl;
}
myfile.close(); //closes the file
}
else
cout << "pathway to file can't be found" << '\n'; //error message to display if file location cant be found.
cin.get();
return 0;
}