Skip to content
This repository has been archived by the owner on Dec 21, 2023. It is now read-only.

An example of a finite state machine

License

Notifications You must be signed in to change notification settings

ADBeveridge/finite-state-machine

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Finite State Machine

The finite state machine (FSM) is an machine that can be in exactly one of a finite number of states at any given time. In these implementations, the machine is represented by the C/C++ function construct.

fsm-struct.c is a implemetation of a FSM where everything is inside of a struct, including the function pointer itself. If you have data, such as a string or integer that is needed, it goes into the struct.

fsm-arg.c is a FSM where you pass data to each function individually. If you have a string or integer to parse through, you have to add it to the function prototypes and definitions.