Hey everyone, I'm pretty stuck right now on this assignment. So I got my read from the first file okay but then I need to compare if the ID gotten from the first file (4th row in classroster.txt) matches any of the ID's from the second file (1st row in studentlist.txt). I need to check it for each of the ID's given by the first file/info[i].ID. So how to I insert the first row's values from the second file and use them in a comparative way, like an if(info[i].ID != ...) I don't really know anything helps.
classroster.txt //
20
Maleeha K Galloway 12832 smallpaul@optonline.net
Autumn J Oconnell 18704 noahb@yahoo.ca
Chaya R Hampton 19628 ralamosm@aol.com
Victoria W Searle 10114 dimensio@gmail.com
Deborah Q Barnett 18172 martink@optonline.net
Maja P Allison 13427 mirod@gmail.com
Darren B Wade 10121 metzzo@yahoo.ca
Amba C Whittington 12673 parksh@yahoo.com
Elisha P Medina 16115 improv@outlook.com
Renesmae Y Crane 17940 dkrishna@optonline.net
Jaiden E Kearns 14066 gavinls@yahoo.com
Lily L Espinoza 10204 dinther@live.com
Pippa Q Chamberlain 15084 qrczak@outlook.com
Keagan N West 19430 doche@verizon.net
Krisha O Montgomery 17526 biglou@gmail.com
Karl E Linebaugh 17156 mosses@live.com
Silva T Pressey 14606 corrada@hotmail.com
Anthony L Contreras 19425 mlewan@aol.com
Gordon G Cisneros 17928 cyrus@live.com
Azul X Rich 16185 jguyer@aol.com
studentlist.txt //
19425 S 1.97
19487 C 3.66
18704 I 3.16
16185 S 2.52
18172 D 3.22
14503 I 3.77
12673 C 3.50
19442 S 1.55
11840 C 3.44
14482 S 3.70
17305 C 3.99
17156 I 2.74
12190 S 3.99
16124 S 3.20
12813 C 2.73
17022 C 2.82
16115 D 3.58
19903 I 3.07
14994 I 3.38
17283 C 2.85
19558 D 1.89
18924 I 1.41
17940 D 3.99
18359 D 2.96
10121 I 2.79
19621 I 3.99
14085 D 1.04
10114 S 3.09
12832 S 2.10
12168 S 1.50
17928 I 3.30
19430 S 3.99
18181 S 1.01
12559 C 2.42
10521 I 3.03
15889 D 1.00
14606 C 3.43
10204 S 3.21
18262 I 3.23
17596 C 1.93
17526 S 2.68
14066 I 3.07
19628 D 2.78
11367 C 3.43
13062 C 1.93
13427 S 2.00
16436 C 3.61
15084 I 3.08
19972 I 3.11
18941 D 1.47
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72
|
#include <iostream>
#include <fstream>
#include <string>
using namespace std;
const int ARRAY_SIZE = 20;
struct nameType
{
string firstName;
char middleInitial;
string lastName;
};
struct studentType
{
nameType name;
int ID;
string email;
double GPA;
enum programType {CSCI, DBMS, INFM, SDEV};
}info[ARRAY_SIZE];
void readClassRoster(ifstream&, studentType[], int&);
void readProgramGPA(ifstream&, studentType[], int);
int main()
{
studentType student[ARRAY_SIZE];
ifstream in;
int students;
ifstream out;
readClassRoster(in, student, students);
readProgramGPA(out, student, students);
return 0;
}
void readClassRoster(ifstream& in, studentType[], int& studentNum)
{
in.open("classroster.txt");
in >> studentNum;
for(int i = 0; i < studentNum; i++)
{
in >> info[i].name.firstName >> info[i].name.middleInitial >> info[i].name.lastName >> info[i].ID >> info[i].email;
}
}
void readProgramGPA(ifstream& out, studentType[], int studentNum)
{
out.open("studentlist.txt");
for(int i = 0; !out.eof(); i++)
{
}
}
|