-Tim McGuire
tmcg...@superior.net, ICQ 5757950
http://www.superior.net/~tmcguire/
> I know that atoi(char*) will change a string into an integer, but how do I
> change an integer into a string???
You should read the FAQ before posting to -any- newsgroup, including this
one. Why don't you go do that now.
--
(initiator of the campaign for grumpiness where grumpiness is due in c.l.c)
Attempting to write in a hybrid which can be compiled by either a C compiler
or a C++ compiler produces a compromise language which combines the drawbacks
of both with the advantages of neither.
-- John Winters <jo...@polo.demon.co.uk> in comp.lang.c
sprintf( ... ) will do the trick for you.
Rick
>Subject: Opposite of atoi()???
>From: Tim McGuire <tmcg...@superior.net>
>Date: Wed, Mar 11, 1998 21:32 EST
>Message-id: <Pine.NEB.3.96.98031...@nimbus.superior.net>
>
>I know that atoi(char*) will change a string into an integer, but how do I
>change an integer into a string???
>
As you doubtlessly saw in the C-FAQ-list, the sprintf function will
do this. Presumably you were just checking to make sure that the
answer in 13.1 is still correct after your last reading of that august
document. I can assure you that its wise counsel is still valid.
--
========================================================================
Bob Nelson -- Dallas, Texas, USA (bne...@iname.com)
Well...Unix, of course. Because windoze is a pathethic toy...
God bless Texas and the death penalty
> I know that atoi(char*) will change a string into an integer, but how do I
> change an integer into a string???
>
> -Tim McGuire
> tmcg...@superior.net, ICQ 5757950
> http://www.superior.net/~tmcguire/
>
>
>
>
sprintf (my_string, "%d", my_int);
Hi Tim McGuire,
From the comp.lang.c FAQ:
13.1: How can I convert numbers to strings (the opposite of atoi)?
Is there an itoa function?
You can get the FAQ at http://www.eskimo.com/~scs/C-faq/top.html or
at ftp://rtfm.mit.edu/pub/usenet/comp.lang.c/C-FAQ-list and it gets
posted to this newsgroup and to news.answers regularly (at the
beginning of each month).
Stephan
(initiator of the campaign against grumpiness in c.l.c)
sprintf();
--
<\___/>
/ O O \
\_____/ FTB.
Bob Nelson wrote:
> Tim McGuire <tmcg...@superior.net> wrote:
> > I know that atoi(char*) will change a string into an integer, but how
> > do I change an integer into a string???
>
>Don't be such an ass....maybe he didn't know about the FAQ (?)
>Obviously new to C programming.
This isn't about C programming, it is about basic netiquette. You should
check whether any newsgroup has a FAQ before posting to it. See
news.announce.newusers for more information.
--
-----------------------------------------
Lawrence Kirby | fr...@genesis.demon.co.uk
Wilts, England | 7073...@compuserve.com
-----------------------------------------
Use the sprintf() function. Like printf() it formats numbers
but instead of its output going to the screen it is stored in a
buffer you specify. For example;
char buffer[80];
int x;
sprintf(buffer, "%i", x);
That will work; there's also an itoa() although I'm not sure if it's in the
standard library.
-Will Flor wi...@will-flor.spamblock.com
Appropriately adjust my return address to reach me via e-mail.
> That will work; there's also an itoa() although I'm not sure if it's in the
> standard library.
It's not. sprintf() seems to be the most common portable solution.
Ryan Younce
> there's also an itoa() although I'm not sure if it's in the standard library.
It isn't.
Raghav,
U forgot the thank your old pal !!
cheers,
chetan
--
[====================================================================]
Chetan Chandrahas Narsude
Senior, Computer Science and Engineering,
Indian Institute of Technology, Bombay.
Phone: +91-022-5906113
Email: chetan....@usa.net HomePage: www.cse.iitb.ernet.in/~ccn
[====================================================================]