Results 1 to 4 of 4
Hi,
Can anyone advise on how to converting a string of char[15] to int. I try using atoi() but the string is too long to be converted.
Regards...
- 06-19-2007 #1Just Joined!
- Join Date
- Feb 2007
- Posts
- 14
Converting string to int
Hi,
Can anyone advise on how to converting a string of char[15] to int. I try using atoi() but the string is too long to be converted.
Regards
- 06-19-2007 #2Linux Enthusiast
- Join Date
- Aug 2006
- Posts
- 631
Use a long variable and convert it with the atol() function.
Regards
- 06-19-2007 #3Just Joined!
- Join Date
- Feb 2007
- Posts
- 14
Hi,
I try atol but it seem that my string is too long cause atol only support up to a length of 11. So when i try to do the following, it return invalid data.
long int li;
char tmp[16];
strcpy(tmp,"99999999999");
ul = atol(tmp); // return 1410065407
regards
- 06-20-2007 #4Linux Enthusiast
- Join Date
- Aug 2006
- Posts
- 631
Define your variable as "unsigned long long" and try te functions strtoll() or strtoug(), Google for examples.
Regards


Reply With Quote