RE: [Dev-C++] itoa - atoi : another implementation
Open Source C & C++ IDE for Windows
Brought to you by:
claplace
|
From: Ioannis V. <iv...@em...> - 2003-04-02 13:10:47
|
In my hurry I forgot the basics:
> -----Original Message-----
> From: dev...@li...
> [mailto:dev...@li...] On Behalf
> Of Ioannis Vranos
> Sent: Wednesday, April 02, 2003 2:46 PM
> To: 'Dev-C++'
> Subject: RE: [Dev-C++] itoa - atoi : another implementation
>
>
> My own contribution to this entirely unneded function:
>
> #include <stddef.h>
> #include <stdlib.h>
> #include <stdio.h>
>
>
> char *itoa(int i)
> {
> size_t Length;
> char *p;
> int temp=i;
>
> for(Length=0; temp/=10; Length++)
> ;
>
> p=malloc((Length+1)*sizeof(i));
if(!p)
return NULL;
>
> sprintf(p, "%d", i);
>
> return p;
> }
>
>
>
> Why would anyone need itoa()? With sprinf() one can easily do the
> conversion.
>
>
> sprintf(s,"%d", i);
>
>
> Ioannis Vranos
>
> * Programming pages: http://www.noicys.freeurl.com
> * Alternative URL: http://run.to/noicys
>
|