Quote:
So
- remove the newline as mentioned in the FAQ
- append the newline to the compare, as in strcmp("q\n", bee)
Yes, me sloppy...
Quote:
Ideally, the while loop should be
while ( !done && fgets(bee, sizeof bee, stdin) != NULL )
So the loop exits when the done flag becomes clear, or the user signals EOF to the input.
> scanf("%d", &n);
Having used fgets() to read one thing, you should use it to read everything. Mixing input functions leads only to pain and confusion.
Eg, replace the scanf with
fgets(line, sizeof line, stdin)
scanf( line, "%d", &n);
where line is a char array similar to bee
That's a good solution.