1
while ((c = fgetc(file)) != EOF && isalpha(c));

I'm either looking at a bug or I'm misunderstanding something. I see how this loop consumes the remaining alpha characters in the current word, and how once it breaks out, we reset index and we go to the next iteration of the for loop, which means we're now looking at the next word.

My question is regarding the apostrophe. Say we're in the loop, and we read (and thus consume) '. That breaks us out of the loop, we reset index, and the for loop assumes we're looking at the next word. If I have that much correct, shouldn't any characters in the "too long" word that follow the apostrophe also be consumed, rather than become a new word which it does now?

0
1

Extra Points to you for reading AND UNDERSTANDING THE CODE!

You are correct, the letters following the apostrophe (or any non-alphas/non-spaces) will be treated as a new word! There are all kinds of fun variations on this. What about hyphenated words, words with other kinds of punctuation in them, or with typos?

However, let's be practical. This is a programming exercise. It would be impractical to write he code in speller.c to cover every scenario exhaustively! It's a programming exercise, not a production program. BUT, it will deliver pretty much flawless data to the functions that you need to write for this exercise. So, just worry about making the functions work as expected and that they will receive words as detailed in the spec.

Again, bonus points for catching this! You deserve a reward! Get yourself an extra twinkie and can of Mountain Dew!!!! ;-)

If this answers your question, please click on the check mark to accept. Let's keep up on forum maintenance!

1
  • Yeah, it doesn't change how I'll write dictionary.c. I'm working on the questions in the readme and just wanted to make sure I understood the details of the for loop. Thanks for confirming! – Allan Clayton Jul 10 '18 at 19:17

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .