2009-08-17

Don't ask...

Some C potchery for a friend...
#include 

int main(void) {
  int state=0;
  char received;
  
  while(1) {
    received=getchar();
    switch (state) {
      case 0:
        if (received=='f')
          state = state++;
        break;
      case 1:
        if (received=='i')
          state = state++;
        else
          state = 0;
        break;
      case 2:
        if (received=='r')
          state = state++;
        else
          state = 0;
        break;
      case 3:
        if (received=='e')
          printf("\n*FIRE!*\n");
        state = 0;
    }
  }
}

0 comments: