Re: Array to integer problem(integer too long).

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Victor -

The number you specify is larger than can be held in a 32 bit integer.
Use atoll instead.

 Brian


On Wed, 16 Feb 2005 12:53:50 +0200, Victor <victor@xxxxxxxx> wrote:
> I have this simple script:
> 
> #include <stdio.h>
> #include <stdlib.h>
> #include <string.h>
> int main(int argc, char **argv) {
>     int test;
>     char *numar = "89126342536";
>     test = atoi(numar);
>     printf("Test: %d", test);
> }
> 
> I want to convert the string numar to integer.
> But the result - when I run the script is :
> Test: 2147483647
> and I would expect:
> Test: 89126342536.
> 
> It seems that the number is too big.
> How can I solve this problem.
> 
> Thank you.
> 
>

[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux