|
From: Reid T. <Rei...@at...> - 2003-04-01 12:43:41
|
char buf[99];
int five =3D 5;
sprintf(buf, "%d", five);
printf(" this is five [%s]\n", buf);
--
thanks,
reid
-----Original Message-----
From: Per Westermark [mailto:pw...@ia...]=20
Sent: Tuesday, April 01, 2003 5:12 AM
To: Ricardo L=F3pez Ruiz
Cc: Khalid El-Kary; Dev-C++
Subject: Re: [Dev-C++] integer to string
Note that while itoa is nonstandard, some implementations take two =
parameters, and some take 3.
The third parameter is then number base, i.e. 2 for binary, 8 for octal, =
etc.
/Per W
On Tue, 1 Apr 2003, Ricardo L=F3pez Ruiz wrote:
> perhaps this example can help you a little more.
> Ricardo.
>
>
> **********ITOA/ATOI **********
>
> #include <stdio.h>
> #include <stdlib.h>
>
> int main()
> {
> char cad[20];
>
> /* the transformation: integer --> string */
> itoa(2003,cad,10); // 2003 is the number to store in cad[]
> printf(cad); // in decimal base =3D 10.
>
> /* and the inverse transformation: string --> integer */
> printf("\n %d",atoi(cad)); // cad[ ] is transformed to =
integer
>
> printf("\n\n");
> system("PAUSE");
> return 0;
> }
>
> *************************************
>
>
>
> -------------------------------------------------------
> This SF.net email is sponsored by: ValueWeb:
> Dedicated Hosting for just $79/mo with 500 GB of bandwidth! No other=20
> company gives more support or power for your dedicated server=20
> http://click.atdmt.com/AFF/go/sdnxxaff00300020aff/direct/01/
> _______________________________________________
> Dev-cpp-users mailing list Dev...@li...
> TO UNSUBSCRIBE: http://www.noicys.cjb.net/devcpp/ub.htm
> https://lists.sourceforge.net/lists/listinfo/dev-cpp-users
>
-------------------------------------------------------
This SF.net email is sponsored by: ValueWeb:=20
Dedicated Hosting for just $79/mo with 500 GB of bandwidth!=20
No other company gives more support or power for your dedicated server =
http://click.atdmt.com/AFF/go/sdnxxaff00300020aff/direct/01/
_______________________________________________
Dev-cpp-users mailing list
Dev...@li...
TO UNSUBSCRIBE: http://www.noicys.cjb.net/devcpp/ub.htm
https://lists.sourceforge.net/lists/listinfo/dev-cpp-users
|