I am trying to create a simple finite state machine in C and I'm quite confused on how to get started. I tried looking online but nothing has really cleared this up for me.
My goal is to check if a string is octal, hex or a decimal.
To be octal the string must start with a 0, followed by digits 0-7. To be hex the string must start with 0x or OX, followed by (a-f, A-F, 0-9)
My attempt at creating the states would be:
typedef enum  {
   ERROR,
   OCTAL,
   HEX,
   DECIMAL
} stringStates;
Now, I would then use a switch statement to go through the entirety of the string and switch between the different states until I have correctly identified which state it belongs to.
 while (current_Position<=end_String-1)
 {
    switch( "input something here")
      {
        case 0:
             //process string
             break;
        case 1:
             //process string
             break;
         case 2:
             //process string
             break;
         case 3:
             //process string
             break;
         default:
             break;
      }
  }
This concept is still very new to me and I'm having hard time understanding its implementation. If anyone can shed some light, it'll be much appreciated.
 
    
