Prev
Up
Next![]()
|
|
My customer reports that the following program has a failure, but it has passed all my test cases successfully. What have I overlooked?
void read_stack (stack *s, char *filename) {
int i;
FILE *f = fopen (filename, "r");
while (!feof (f)) {
fscanf (f, "%d", &i);
push (s, i);
}
}
int main () {
stack *sp = new_stack ();
int sum = 0;
read_stack (sp, "myfile.stack");
do
sum = sum + pop (sp);
while (! is_empty (sp));
}
![]()