How can I get correct result:
char * str;
str = "10974000000";
i = atoi(str);
printf("i=" , i);
----- output:
i=2617245696
The function atoi() attempts to convert a text string representing a
numeric value into a signed int. If the result of the conversion is
outside the range of values that a signed int can hold, the behavior
is undefined.
What is the range of type signed int on your platform? You can find
the macros INT_MIN and INT_MAX in the <limits.h> header. Most likely,
the largest value that your int can hold is less than 10974000000, so
you are trying to pour 10 quarts of water into a 5 quart pitcher.
Note that the strto* functions (strtol, strtoul, strtod) prototyped in
<stdlib.h> are much better and safer than the ato* functions. They
will not even try to put a value that won't fit into a result, and
they provide indications in errno if there is a problem.