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?
It is a common assumption that warnings can be ignored - anything that creates a binary should be good to go.
It is a common assumption that warnings can be ignored
Well, I don't have to tell you, Per, but for the record: most of the time, using sensible tools, that assumption is wrong. Especially so if the person doing the ignoring doesn't know enough C to even understand the warnings' meaning.
Only if you're sure you could explain convincingly to both your grandma and your boss why exactly you're getting this particular warning about this particular piece of code, and why it's harmless in this particular case, you can ignore it. Actually in that case you may even go ahead and disable it for this particular case, if the tools have sufficiently fine-grained control over warnings. That's one reason why LINT is more important than the C compiler in the business of checking warnings: its warnings have the finest controls you're likely to find in any tool.
Yes, I did get warnings about 'statements that do nothing' but these warnings were for two while (1) statements, not for the atoi statement detailed above.
I have the warning level set to the highest in the compiler.
Do have a recomendation for a lint program?
Jason
PC-Lint from Gimpel Software. Bradford
I am using version 9. An occasional life saver.
Ok I will give it a try.
My program is now working 100%. The serial input routine is working and the atoi is also working correctly. I spent the better part of the last few days testing the system and inputing both good and bad data and it works correctly.
My thanks for the feedback and guidance.