Skip to content

Instantly share code, notes, and snippets.

View inderpreet's full-sized avatar

Inderpreet Singh inderpreet

View GitHub Profile
@nmandery
nmandery / statemachine.c
Created February 1, 2012 14:55
State machines are very simple in C if you use function pointers.
/*
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.
*/