Frankly, I fear you've lead this thread astray.
You don't need a "Finite State Machine" or convoluted logic to count words. Certainly, no goto's are required (although I use them w/o guilt, as K&R advocated in the White Book).
To count words, I just:
This is without actual coding & testing, but I believe it will do the job.Code:add_word = 1 while char's remain unread in the string read a char in the string. If it's a letter, and add_word flag is 1 increment the word count, set add_word flag to 0 if char is a space, set add_word flag to 1 loop
The add_word variable is key to a simple loop logic for this.
Adak


