blob: d173b1f6a6e3e18abb27e159922050de86b133a2 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
|
13a - CH11.7 Exercises:
#5:
if(!testFile.fail) //Part a
{
testFile >> lname[0] >> id[0] >> age[0]; //Part b
cout << lname[0] << " " << id[0] << " " << age[0] << " " << endl;
while(!testFile.eof())
{
index++;
testFile >> lname[index] >> id[index] >> age[index];
cout << lname[index] << " " << id[index] << " " << age[index] << " " << endl;
}
testFile.close(); //Part c
}
#6:
a) False: RAM is much faster; RAM is faster than everything else except for the CPU's cache and registers
b) True: Who knows what strange files people will feed into your program.
c) True: Since you've read in the data, and know what you've modified, why would you need to read it again? (Unless its realy big)
d) True: Unless you don't need to know how much you've read for some reason. There are workarounds if you forget.
e) True: The OS will put an EOF in the file if there is not one already.
|