>Hope This is Clear enough
Not really. Explaining how you're going to do something is irrelevant if we don't know what it will be used for. Knowing the end result is a key element in determining how to approach a problem.
>Iam not able to decide what data structures to use to manupulate data.
Every state has an input and an output, so a simple data structure or no data structure will usually suffice. You'll find that most state machines are implemented as an array of function pointers that take the initial state as an argument and return the next state. Alternative designs use a table of IN/OUT states that do basically the same thing.
Narue
Bad Cop
15,460 posts since Sep 2004
Reputation Points: 6,464
Solved Threads: 1,401
what is an arrray of fuction pointers?? Plz explain.
Not the easiest thing to explain, sometimes.
#include <stdio.h>
int foo(void) { return 1; }
int bar(void) { return 2; }
int baz(void) { return 3; }
int main()
{
int (*afp[])(void) = { foo, bar, baz };
int i;
for (i = 0; i < sizeof afp / sizeof *afp; ++i )
{
printf("afp[%d]() = %d\n", i, afp[i]());
}
return 0;
}
/* my output
afp[0]() = 1
afp[1]() = 2
afp[2]() = 3
*/
More info: http://www.newty.de/fpt/index.html
Dave Sinkula
long time no c
5,058 posts since Apr 2004
Reputation Points: 2,780
Solved Threads: 314