|
|
FOR each ID in classroster.txt IF ID is in studentlist.txt THEN what |
|
|
|
|
To answer your question, I'm not sure what you mean by makes a type |
So how to I put the ID information gotten from studentlist.txt into an array, with skipping the letter for class and the GPA (because it screws the code up and causes a segmentation fault). Should I create a separate struct to store the info from studentlist.txt? Make a multi-dimensional array? Or is there just a way to skip it? |
A function to assign the relevant program and GPA to each student. This function will open studentlist.txt. You will have to search the student array to find the student from the file and assign their program and GPA. If a student from the file is not found in the array skip it and go to the next student in the file. A function to find a student by id in the array. This function should do a search on the array and return the position of the student with a matching student id, or -1 if the student is not in the array. |
void readProgramGPA(ifstream&, studentType[], int); Really could use some variable names here will read the file "studentlist.txt" then call the function: int findStudentByID(int, const studentType[], int) to actually search the array. I used a simple for loop here to return the index of the array or (-1) if nothing was found. |
|
STUDENT INFORMATION
--------------------------------------------------------------
Id | Name | GPA | E-mail
--------------------------------------------------------------
12832 Maleeha K, Maleeha 2.10 smallpaul@optonline.net
18704 Autumn J, Autumn 3.16 noahb@yahoo.ca
19628 Chaya R, Chaya 2.78 ralamosm@aol.com
10114 Victoria W, Victoria 3.09 dimensio@gmail.com
18172 Deborah Q, Deborah 3.22 martink@optonline.net
13427 Maja P, Maja 2.00 mirod@gmail.com
10121 Darren B, Darren 2.79 metzzo@yahoo.ca
12673 Amba C, Amba 3.50 parksh@yahoo.com
16115 Elisha P, Elisha 3.58 improv@outlook.com
17940 Renesmae Y, Renesmae 3.99 dkrishna@optonline.net
14066 Jaiden E, Jaiden 3.07 gavinls@yahoo.com
10204 Lily L, Lily 3.21 dinther@live.com
15084 Pippa Q, Pippa 3.08 qrczak@outlook.com
19430 Keagan N, Keagan 3.99 doche@verizon.net
17526 Krisha O, Krisha 2.68 biglou@gmail.com
17156 Karl E, Karl 2.74 mosses@live.com
14606 Silva T, Silva 3.43 corrada@hotmail.com
19425 Anthony L, Anthony 1.97 mlewan@aol.com
17928 Gordon G, Gordon 3.30 cyrus@live.com
16185 Azul X, Azul 2.52 jguyer@aol.com
|
|
|
|
|
!in.eof is that you are checking this before you read the file which would set the "eof" bit. When the inside of the loop sets "eof" you are still going to process nothing before it adds 1 to "i" and checks for "eof".
STUDENT INFORMATION
--------------------------------------------------------------
Id | Name | PROGRAM | GPA | E-mail
--------------------------------------------------------------
12832 Maleeha K Galloway SDEV 2.10 smallpaul@optonline.net
18704 Autumn J Oconnell INFM 3.16 noahb@yahoo.ca
19628 Chaya R Hampton DBMS 2.78 ralamosm@aol.com
10114 Victoria W Searle SDEV 3.09 dimensio@gmail.com
18172 Deborah Q Barnett DBMS 3.22 martink@optonline.net
13427 Maja P Allison SDEV 2.00 mirod@gmail.com
10121 Darren B Wade INFM 2.79 metzzo@yahoo.ca
12673 Amba C Whittington CSCI 3.50 parksh@yahoo.com
16115 Elisha P Medina DBMS 3.58 improv@outlook.com
17940 Renesmae Y Crane DBMS 3.99 dkrishna@optonline.net
14066 Jaiden E Kearns INFM 3.07 gavinls@yahoo.com
10204 Lily L Espinoza SDEV 3.21 dinther@live.com
15084 Pippa Q Chamberlain INFM 3.08 qrczak@outlook.com
19430 Keagan N West SDEV 3.99 doche@verizon.net
17526 Krisha O Montgomery SDEV 2.68 biglou@gmail.com
17156 Karl E Linebaugh INFM 2.74 mosses@live.com
14606 Silva T Pressey CSCI 3.43 corrada@hotmail.com
19425 Anthony L Contreras SDEV 1.97 mlewan@aol.com
17928 Gordon G Cisneros INFM 3.30 cyrus@live.com
16185 Azul X Rich SDEV 2.52 jguyer@aol.com
Press Enter to continue:
|
|
|
|
|
12832 Maleeha K Galloway S 2.10 smallpaul@optonline.net 18704 Autumn J Oconnell I 3.16 noahb@yahoo.ca 19628 Chaya R Hampton D 2.78 ralamosm@aol.com 10114 Victoria W Searle S 3.09 dimensio@gmail.com 18172 Deborah Q Barnett D 3.22 martink@optonline.net 13427 Maja P Allison S 2.00 mirod@gmail.com 10121 Darren B Wade I 2.79 metzzo@yahoo.ca 12673 Amba C Whittington C 3.50 parksh@yahoo.com 16115 Elisha P Medina D 3.58 improv@outlook.com 17940 Renesmae Y Crane D 3.99 dkrishna@optonline.net 14066 Jaiden E Kearns I 3.07 gavinls@yahoo.com 10204 Lily L Espinoza S 3.21 dinther@live.com 15084 Pippa Q Chamberlain I 3.08 qrczak@outlook.com 19430 Keagan N West S 3.99 doche@verizon.net 17526 Krisha O Montgomery S 2.68 biglou@gmail.com 17156 Karl E Linebaugh I 2.74 mosses@live.com 14606 Silva T Pressey C 3.43 corrada@hotmail.com 19425 Anthony L Contreras S 1.97 mlewan@aol.com 17928 Gordon G Cisneros I 3.30 cyrus@live.com 16185 Azul X Rich S 2.52 jguyer@aol.com |
Here's what I have right now, am I at least on the right track? |
When I go any farther I just mess it up, I'm unfortunately at the point of just giving up I'm making no progress and just sitting her guessing-and-checking being unproductive with no prevail :/ |
|
|
1. You say don't use a global variable instead of the info[ARRAY_SIZE] so how do I make that array local and use it around my code, i.e. inputting into with external file, passing around by reference? Where should that be located and what should it look like? |
|
|
|
|
|
|
2. Should I make a separate array/struct to retain the information brought in by classroster.txt? |
3. What is the int I should use in my, findStudentByID references? |
|
|
|
|
4. Where should my enum for programType be placed, in the struct of studentType or in the global space? 1. I don't know if it's my IDE but I'm not allowed to make an enum a constant. |
|
|
|
|
studentType[], should be a compiler error or at least a warning because you did ot give it a variable name nor do you use them in the functions. You are probably still using that global variable. |
|
|
|
|
|
const studentType[] is not enough. It is missing the variable name. If you are still using the global variable "info" then it will not matter unless it is a compiler error.