This code is reading a file visitors.txt and the file has a list of information like this:
int
Name, enumerated data type, int, int, int, int
name, edt, int, int, int, int
name, edt, int, int, int, int
name, edt, int, int, int, int
etc.
i want to skip the first int, and take in the rest of the values. I think I might've messed up while trying to skip the commas. When I run the program it keeps printing out "didn't pink up the Type of Visitor" in an infinite loop.....ahh! help! Here's the code:
Code:
char char_ignore[5],char_name[25],char_numType[10], char_numAH[3], char_numAM[3], char_numDurH[3], char_numDurM[3];
fstream file;
file.open("visitors.txt");
if(file.is_open())
{
file.getline(char_ignore,5,'\n');
while(!file.eof())
{
file.getline(char_name,25,',');
file.ignore();
file.getline(char_numType,10,',');
file.ignore();
file.getline(char_numAH,3,',');
file.ignore();
file.getline(char_numAM,3,',');
file.ignore();
file.getline(char_numDurH,3,',');
file.ignore();
file.getline(char_numDurM,3,',');
file.ignore();
Visitor temp;
temp.name = (string)char_name;
if((string)char_numType == "UNDERGRAD")
temp.type = UNDERGRAD;
else if((string)char_numType == "GRAD")
temp.type = GRAD;
else if((string)char_numType == "PROF")
temp.type = PROF;
else
cout << "Didn't pick up the Type of Visitor";
temp.a_hours = (int)char_numAH;
temp.a_mins = (int)char_numAM;
temp.d_hours = (int)char_numDurH;
temp.d_mins = (int)char_numDurM;
fifo.push(temp);
}
file.close();
}