-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathutils.cpp
More file actions
77 lines (64 loc) · 2.2 KB
/
Copy pathutils.cpp
File metadata and controls
77 lines (64 loc) · 2.2 KB
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
73
74
75
76
77
#include "program3.h"
/*********************************************************************
void processCourseInformation(ifstream& fileInput, Course* courseArr, Student* studentArr, int& courseCount, int& studentCount);
Purpose:
Loop through the text file and process each file into the respective arrays.
Parameters:
I ifstream& fileInput -- read the file input
I/O Course* courseArr -- dynamically allocated array for course
I/O Student* studentArr -- dynamically allocated array for student
I/O int& courseCount -- number of courses
I/O int& studentCount -- number of students
Return Value:
-
Notes:
Loops till eof so reads the course info, the capacity and then the student info.
*********************************************************************/
void processCourseInformation(ifstream& fileInput, Course* courseArr, Student* studentArr, int& courseCount, int& studentCount)
{
courseCount = 0;
studentCount = 0;
string szLine;
//read the entire line
while(getline(fileInput, szLine))
{
string szCID, szCName;
istringstream stream(szLine);
//1st token
stream >> szCID;
//for the rest of the tokens
string szTemp;
while(stream >> szTemp)
{
szCName += szTemp + " ";
}
//remove space at the end
szCName.pop_back();
int iCap;
fileInput >> iCap;
fileInput.ignore();
courseArr[courseCount] = Course(szCID, szCName, iCap);
courseCount++;
//Reading the students now
while(getline(fileInput, szLine))
{
if(szLine == "*********************")
break;
string szSID, szSName;
istringstream stream(szLine);
//1st token
stream >> szSID;
//for the rest of the tokens
string szTemp;
while(stream >> szTemp)
{
szSName += szTemp + " ";
}
//remove space at the end
szSName.pop_back();
studentArr[studentCount] = Student(szSID, szSName);
courseArr[courseCount-1].enrollStudent(studentArr[studentCount]);
studentCount++;
}
}
}