This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

atoi, strol functions problems

Hello,

I work with LPC2148 and RealView Compiler.

I have noticed that if I convert a string with the atoi function, the result never is correct.
If the value of the number in the string is inferior to 20 the result is 0. If the value of the number is great of 20 the result is equal to the number subtracted to 20.

Example 1:

char sbuffer[] = "12";
int buffer;
buffer = atoi(sbuffer);
//now buffer = 0 (I waited for 12).

Example 2:

char sbuffer[] = "29";
int buffer;
buffer = atoi(sbuffer);
//now buffer = 9 (I waited for 29).

Probably the problem is with strtol (function used by atoi), perhaps with the number base? But the number base of strtol is not automatic with atoi?

Is there some suggestion? Thank you.

M.

Parents Reply Children
No data