Mail Archives: djgpp/1999/08/15/23:12:54
Dan Gold <TedMat AT CoastNet DOT com> wrote in message
news:199908142250 DOT SAA05391 AT delorie DOT com...
> itoa(),
> ex.
> itoa(integer, string, 10);
>
> Well thats how I do it and it works...=)
> from Dan Gold
> ----------
> > From: BuckTheMan <cvasser AT home DOT com>
> > To: djgpp AT delorie DOT com
> > Subject: Integer to String
> > Date: Saturday, August 14, 1999 6:59 AM
> >
> > How could I convert an integer to a string, I know atoi converts a
string
> to
> > an intger, but thats the opposite of what I need.
> >
> >
void sprintf(char *out, const char *format, ...)
/* Another way to do it is sprintf(), which lets you control the way the
number is formatted in the string. Look up printf() in your favorite C
reference for more info.
example: */
char strbuf[256];
int score;
sprintf(strbuf, "Score:%7d", score);
/* This would convert the integer to a string, right align it, and put
"Score" before it. Change the 'd' in the format string to an 'x' to use
hexadecimal. */
Damian Yerrick (comp DOT os DOT msdos DOT djgpp AT pineight DOT 8m DOT com)
Help defeat spam by tracing where they got their mail addresses. Get an
entire domain of e-mail addresses at http://www.freeservers.com
- Raw text -