i have an array and struct i read the first file fine the second file im having a problem with because all the id are not in order so how would i compare two struct with '==' and match the id together because everytime i do this it doesnt print anything because im completely lost
text file student:
0 billy A
1 matt A
2 mike B
3 john C
4 kat D
5 cindy C
6 vera A
7 tom B
8 bob D
9 dave C
10 ant A
text file gpa:
10 4 Math
2 3 Math
3 2 Science
7 3 history
8 1 english
9 2 English
5 2 science
6 4 Math
4 1 English
1 4 history
0 4 history
so i dont get is how you would match files from a struct and array so that the 10 match with 10 element would you compare structs "==" or would it be something different. i can use void function also
@ghost1111
A couple of problems. You had for loops wrong. It would be for(i=0 ; i < 11 ; i++).
Not >, which is greater than.
Anyway, here's how to fill the structs, and cout them in the order of the student number, so they all match up.
You had int num at the start of your source, so I just used it, so I could keep the console open after the program runs.
wouldnt they all just line up with each other
What are you meaning here?
If you're referring to studentInfo and student_GPA_Info, then, no. The second set, student_GPA_Info, is not in the same order as studentInfo, so we do a loop to find the same student number in each set, and print it out on the same line. Then print a new line or, endl.
If you want consecutive lines, with no space between then, remove the '<< endl' on line 64, but leave the semi-colon