Hi, I am currently working on a student records program and I want it to print a '-' after every 3 digits from the Id number that I read from the file(ID number from file doesn't have the dashes). How would I do that to print it with dashes? Thank you
Here are my reading functions.
Code:
void Read_Student(Student & Temp , ifstream & fin){
fin >> Temp.FirstName;
fin >> Temp.LastName;
fin >> Temp.Id;
fin >> Temp.Quiz;
for (int i = 0 ; i < 6 ; i++)
fin >> Temp.Test[i];
fin.ignore(10,'\n');
}
int Read_List(Student & Temp,Student List[], int Max_Size)
{
ifstream fin;
int i = 0;
if (Open_File(fin))
{
getline(fin, List[i].Course_Name);
getline(fin, List[i].Course_Id);
getline(fin, List[i].Course_Location);
Read_Student(List[i],fin);
while(!fin.eof())
{
i++ ;
if (i == Max_Size){
cout << "\nArray is full.\n" ;
break;
}
Read_Student(List[i],fin);
}
}
else
{
cout <<"\nBad file. Did not open. Program terminated.\n";
exit(0);
}
return (i);
}
SAMPLE INPUT:
Code:
Intro To Computer Science C++
SAL 343
JHG 344
John Adams
111223333 100 87 93 90 90 89 91
Willy Smith
222114444 90 73 67 -77 70 80 90
Phil Jordan
777886666 100 80 70 -50 60 90 100
One more thing, I also am having problems with reading last name. If I edited the inout file and had for example John Adams Jr. it would cause huge print problems. When I remove it it prints out perfectly. Any advice on that too please