%expand%
char* itoa(int val, char *buf, int base) {
int m = sizeof(int)*(base >=10 ? 4 : 8)-1;
int i = m;
int j = 0;
if (base > 100 || base < 2)
return NULL;
if (val < 0) {
val = -val;
buf[0]='-';
j = 1;
} else if (!val) {
buf[0]='0';
buf[1]='\0';
return buf;
}
for(; val && i ; --i, val /= base)
buf[i] = '0' + (val % base);
for (;i < m; ++i, ++j) {
buf[j]=buf[i+1];
}
buf[j]='\0';
return buf;
}}))
| Bracing against the wind | |
| www.documentroot.com |
|
Wednesday, January 20, 2010
With the same sort of mild insanity that afflicts many standards making bodies, itoa has been removed from gcc.
[View/Post Comments] [Digg] [Del.icio.us] [Stumble] |
|
Bloghop:
|
Blogarama
|
Technorati
|
Blogwise