Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

3
  • 1
    Might be worth putting "state" inside the function, and making it static. Commented May 11, 2009 at 22:40
  • 2
    @Steve Melnikoff: only if you've only got one state machine. Keep it outside the function and you can have an array of state machines with their own state. Commented Jun 25, 2010 at 12:09
  • @Vicky: One function can contain as many state machines as you like, with an array of state variables if required, which can live inside the function (as static variables) if they're not used elsewhere. Commented Jun 28, 2010 at 12:07