This checks if stdin contains the phrase 'foo' or 'bar'
#include <stdio.h> main() { int c; START: switch(c = getchar()){ case 'f' : goto F; case 'b' : goto B; case EOF : goto FAIL; default: goto START; } F: switch(c = getchar()){ case 'o' : goto FO; case EOF : goto FAIL; default : goto START;} FO: switch(c = getchar()){ case 'o' : goto SUCCESS; case EOF : goto FAIL; default : goto START;} B: switch(c = getchar()){ case 'a' : goto BA; case EOF : goto FAIL; default : goto START;} BA: switch(c = getchar()){ case 'r' : goto SUCCESS; case EOF : goto FAIL; default : goto START;} FAIL: printf("Does not match.\n"); return; SUCCESS: printf("Matches.\n"); return; }