How can I make atoi work in my ADS project?
Question
I want to use atoi
function in my program, but I found it not working.
#include <ctype.h>
int value;
value=atoi(buf);
char buf
points to "1000" or something like, terminated by \0
. I have checked it.
But the value evaluates always to zero. I have tried strtol()
, but I get the same error.
- My ADS (ARM Developer Suit) is v1.2 (s3c2440). I can find the libs in armlib path (c_t_xx.l).
- I use
axd
debug mode, so I can trace my code. I found"bl
, so I think asm code linked right.
__rt_ctype_table"
Please give any advice to fix this issue.
Solution
ARM might have a problem with string functions, you haven't mentioned whether it returns a value and it's incorrect (i heard it's a bug and it's better you should write the function on your own) or there is no value at all. anyway look at the arm article about it i think it's the solution - ARM article about string functions
OTHER TIPS
The following code should work,
#include <stdio.h>
#include <stdlib.h>
int main()
{
int i;
char buff[5] = "1000\0";
i=atoi(buff);
printf("i=%d\n", i);
return 0;
}
#./a.out
#i=1000
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow