I am having problems getting atoi to work.
here is how I populate the comin[] array
do { comin[index] = (getchar()); ++index; } while (index<=4);
later in the program I do the following:-
command = atoi(comin);
expecting to get a 4 digit number in command. comin is working fine - no problems. But command is always 0 (zero). I have tried quite a few things, but no luck. I did a search on the forum andd came up with this
http://www.keil.com/forum/docs/thread10470.asp
Anybody else had this problem or know a work around?
Note that "\n" is a C string. The value of the C string is the address of the first character in the string.
What you want to do is to compare characters, so you should use a character constant.
if (comin[5] == '\n') { ... }
Notice the difference between single and double quotes.
The atoi statement is wroking now - thank you. I have mad e similar errors in other sections of the code - these are also fixed now.
Jason