Name: ____________________________________________________ Alpha: _____________________
Describe help received: _________________________________________________________________
See the bottom for how to submit your work.
Simple data bucketingDebug your code until it runs correctly. Circle below how you wrote your code.
[10pts] See the code below.
ifstream fin("foo.txt");
int count = 0;
char c = 'x';
while(fin)
{
if (c == '?')
count = count + 1;
fin >> c;
}
cout << count << endl;
What exceptional condition would cause the program to never enter the while loop?
Suppose the program entered the while loop. What would cause the program to exit the loop?
|
|
~$ ./hw Filename: input.txt Brown 71.8 Green 93.8 Jones 82.4 Smith 86.2 Worth 91.2 The best student is Green.
Your program should work for any file in the same format. Another example run with test.txt (download it into a VM before running your program):
~$ ./hw Filename: test.txt Abel 85.4 Dean 88.8 Jade 84 Mood 78.2 Noon 83.8 Wren 62 Zoom 85.2 The best student is Dean.
~/bin/submit -c=IC210 -p=hw09 hw.cpp