2

I make a DFA Simulator.

if Node 0 is initial state and Node 3 is final state, like weight graph implementation.

char CurrentStateAccept[stateN][alphabetN][alphabetN] = { {"01"} , {"0"} , {"0","1"} ,{} }; // 0, 1, 2, 3
int NextState[stateN][alphabetN] = {{1},{2},{0,3},{}};

I want to get 1, 1, 2, 0

  • node 0, accept(0 or 1) -> node 1
  • node 1, accept(0) -> node 2
  • node 2, accept(0) -> node 0
  • node 2, accept(1) -> node 3
  • and node 3 is final state of dfa.

so I want to get char CurrentStateAccept[each state]'s element number for using 'for loop' ex)

for(i=0; i<currentState element num; i++)
{
   for(j=0; j<end of alphabet of each element; j++)
   {
       there is acceptable state? or not?
   }
}

How can I get in C?

1 Answer 1

3

you mean something like this

sizeof(array)/sizeof(type of array);
Sign up to request clarification or add additional context in comments.

1 Comment

Or, even easier: (sizeof array / sizeof array[0])

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.