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.

  1. My ADS (ARM Developer Suit) is v1.2 (s3c2440). I can find the libs in armlib path (c_t_xx.l).
  2. I use axd debug mode, so I can trace my code. I found "bl
    __rt_ctype_table"
    , so I think asm code linked right.

Please give any advice to fix this issue.

Was it helpful?

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
scroll top