/*
a demonstration of a very simple "state" program.

Ray Ontko 1999/09/29
*/

#include <stdio.h>

main()
{
int c ;
int count = 0 ;
int state = 0 ;

while ( ( c = getchar() ) != EOF )
  {
  if ( state == 0 )
    {
    if ( isalpha( c ) )
      {
      count ++ ;
      state = 1 ;
      }
    }
  else if ( state == 1 )
    {
    if ( ! isalpha( c ) )
      {
      state = 0 ;
      }
    }
  }

printf( "count = %d\n" , count ) ;
printf( "state = %d\n" , state ) ;
}
