ok here is my new function.
I am still trying to debug it. Can you pros figure out the problem with the second while loop. The program freezes there and i'm not sure why. The logic behind the code seems find but the code itself is problematic. Thanks for your time.
Code:
void read_data(int ID,istream& in)
{
int number = ID;
cout<<"Student ID: "<<number<<endl;
fstream data;
string line, line2;
string class_name;
int counter = 0;
int ident;
char ch;
char mark;
while (counter < 7)
{
getline(in,line);
istringstream instr(line);
while (instr.get(ch))
{
while (ch!='\n')
{
instr>>class_name;
}
data.open("class_name.dat");
getline(data,line2);
istringstream instream(line2);
while (instream.get(ch))
{
while (ch!='\n')
{
if (isdigit(ch))
{
instream>>ident;
}
else if (isspace(ch))
{
instream>>mark;
}
if(ident != ID)
{
break;
}
else
{
cout<<class_name<<" "<<mark<<endl;
}
}
data.close();
}
}
counter ++;
}
}