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
78
79
80
81
82
83
84
85
86
87
|
CST 116 Austin Guertin
13a 11.7 pg 317 #5-6 (Statements for 5, Judgements for 6)
5)
.cpp
#include <fstream>
#include <iostream>
#include <string>
using namespace std;
const int RECORDS = 100;
const int MAX = 4;
int main()
{
string records[RECORDS];
int num_records = 0;
//Open the file
ifstream inFile;
ofstream outFile;
inFile.open("C:\\TEMP\\13a_number5_data.txt");
outFile.open("C:\\TEMP\\13a_number5_report.txt");
//Check to see if file is open (a)
if (inFile.is_open() && outFile.is_open())
{
cout << "\n\n";
// Read until end of file is reached
while (!inFile.eof())
{
//Priming read (b)
getline(inFile, records[num_records], ' ');
cout << records[num_records];
outFile << records[num_records];
num_records++;
}
cout << "\n\n\n\n";
//close the file (c)
inFile.close();
}
else
{
cout << "ERROR: This file could not be opened for some reason\n\n";
return num_records;
}
}
13a_number5_data - Notepad
lname1, id1, age
lname2, id2, age
lname3, id3, age
lname4, id4, age
lname5, id5, age
lname6, id6, age
13a_number5_report - Notepad
lname1,id1,age
lname2,id2,age
lname3,id3,age
lname4,id4,age
lname5,id5,age
lname6,id6,age
6)
a. False
13b 11.9 pg 323 #1 (Write a full program to call the function)
13c 11.13 pg 333-336
11.14 pg 336-337 #1
|