Ricardo Lopez Camino wrote:
On Thu, 25 Mar 2004 10:54:25 -0500 Bob Pearson
wrote: On Thursday 25 March 2004 10:39 am, Ricardo Lopez Camino wrote:
Hi, I need an easy example for understand an FSM in C++. Thanks, in advance........
When you code, in any language, you quite often uses an FSM. For, example, this is an state machine I often use (when I can't use getopt): uint state = 0; for(uint i = 0; i < argc; ++i) { if(state == 0 && strcmp(argv[i], "-i") == 0){ state = 1; } else if(state = 1) { input = optarg; state = 0; } else if(state == 0 && strcmp(argv[i], "-o") == 0) { state = 2; } else if(state = 2) { output = optarg; } else { usage(argv[0]); exit(1); } } You probably want a library where you can draw your graph with transitions and let it do the hard work. There are several of these out there, with stuff like states minimization and so on. But none of them is really popular. Maybe you should look at ragel library. But, most often, you end up writing code yourself. []s Davi de Castro Reis