Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

atoll( ) problem

Status
Not open for further replies.

logic4fun

Programmer
Apr 24, 2003
85
0
0
US
Hi all,
i am trying to convert a string to long long int as it is very big using follwing code..

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main(void)
{
int i;
char str[4];
char str3[10];
char str2[6];
char str1[4];
char strMain[30];
long long finalString;

printf(&quot;Enter your Number : \n&quot;);
scanf(&quot;%d&quot;,&i);
sprintf(str3,&quot;%d&quot;,i);
strcat(strMain,str3);

printf(&quot;Enter your Number : \n&quot;);
scanf(&quot;%d&quot;,&i);
sprintf(str,&quot;%d&quot;,i);
strcat(strMain,str);

printf(&quot;Enter your Number : \n&quot;);
scanf(&quot;%d&quot;,&i);
sprintf(str2,&quot;%d&quot;,i);
strcat(strMain,str2);

finalString = atoll(strMain);

printf(&quot;final values are string - %s integer - %lld \n&quot;,strMain,finalString);
}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
and this code won't compile and says
ld: 0711-317 ERROR: Undefined symbol: .atoll
ld: 0711-345 Use the -bloadmap or -bnoquiet option to obtain more information


Anysuggestions in this regard I want to concatenate three integers into one long integer
eg : 1050444444 + 1234 + 4567
i need 105044444412344567

Thanks in Advance
Logic4Fun
 
atoll isn't part of C89, but is part of C99 (the new C standard). However, most C compilers are C89 compilers and therefore may not provide atoll. See the compiler documentation and see the linker options mentioned in the diagnostic.

If your compiler doesn't provide it, there may be atoll implementations on the web or maybe glibc provides it and you can hack it out of there.
 
Try using atol().

This funciton should do what you want.

Hope this helps.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top