Converting char to int

I am writing a program for a Finite State Machine. The machine gets an input of either 'a' or 'b' from a text file. I need to convert this character into an integer so that I can use it to change states. I can't use the STL so atoi won't work and whenever I use int(in_char) and that works but eventually gives me a segmentation fault. Why is the segmentation fault happening? My code for changing the state is:
cur_state = table_array[cur_state][int (in_char) +1];
Update: it does run with one character but if the input file has more than one character, it gives the segmentation fault
Last edited on
The machine gets an input of either 'a' or 'b' from a text file. I need to convert this character into an integer so that I can use it to change states.

What "integer" value do you expect to convert 'a' or 'b' to?
Topic archived. No new replies allowed.