line 52
inputFile.ignore(100, '\n')
what the need for 100, '\n'?? |
If we consider the input file:
Duck, Daffy
77.3
Pluto
88.0 |
that could be represented like this:
|
"Duck, Daffy\n77.3\nPluto\n88.0\n"
|
or possibly like this:
|
"Duck, Daffy\n 77.3 \n Pluto \n 88.0 \n"
|
We know there is definitely
at least one character after the average figure - the newline, hence a simple
ignore()
is the minimum. But if there happened to be a space or more before the newline, it might not be enough. A natural caution leads me to prefer to cover the possibility of there being some extraneous character in there. In that case, ignore(100, '\n') would deal with anything from 0 to 99 spaces preceding the newline. If you yourself are certain that there will never be a need for this, then just use a single ignore(). There are other ways of dealing with unwanted whitespace, using the std::ws manipulator. You might as an alternative try
inputFile >> ws;
at line 51. Try these ideas out, try using neither, try one, try the other, experiment and see what happens, that's the way to find out.
http://www.cplusplus.com/reference/istream/istream/ignore/
http://www.cplusplus.com/reference/istream/ws/
in another functionjavascript:editbox1.editPreview()
so ]the prototype
void grades(double[], char[])
is that good do i need anything else? |
Well, the first function,
inputData
has a loop which repeats a particular number of times, depending on the file content. The function
grades
will need to loop that
same number of times. But it won't read the file all over again to count the number of times to repeat. Instead, you need to take the value of
count
which should be returned by the first function and pass it as a parameter to the function grades.