Skip to content

Instantly share code, notes, and snippets.

Avatar

Inderpreet Singh inderpreet

View GitHub Profile
@nmandery
nmandery / statemachine.c
Created Feb 1, 2012
State machines are very simple in C if you use function pointers.
View statemachine.c
/*
http://stackoverflow.com/questions/1371460/state-machines-tutorials/1371654#1371654
State machines are very simple in C if you use function pointers.
Basically you need 2 arrays - one for state function pointers and one for state
transition rules. Every state function returns the code, you lookup state
transition table by state and return code to find the next state and then
just execute it.
*/