| Username |
Post |
| sainju_fan |
Posted
on 30-Apr-02 06:16 AM
Sainju ji, (or anyone else who could help... no VC++ solutions pls....) Is there a way to use "itoa()" in GCC without having to dig into the GCC itself for fixes? GCC claims it is a non standard function. code seg: { int x = 123; char y[4]; strcat(itoa(x, y, 4), "_chr"); } dhanyabaad
|
| SMSainju |
Posted
on 30-Apr-02 08:54 AM
itoa is not supported by ANSI C. Sorry I don't do Visual C++. but here is the mechanics of how itoa() should work. void itoa (int n, char s[]) /* it converts n to characters in s */ { int i, sign; if ((sign = n) <0) n = -n; i = 0; do { s[i++] = n%10+'0'; }while((n/=10)>0); if (sign <0) s[i++] = '-'; s[i] = '\0'; reverse(s); } for reverse(), just loop thru the string and copy using swap. hope this helps.. SMSainju
|
| SMSainju |
Posted
on 30-Apr-02 08:55 AM
you should be able to find solutions in Brian Kernighan and Dennis Ritchie's book. SMSainju
|
| sainju_fan |
Posted
on 30-Apr-02 10:31 AM
Dhanyabaad Sainju ji I was able to work around it with slight modifications to what you gave... tapaai ko pankha
|