ak**************@gmail.com wrote:
What is the most easiest way to convert an integer value to ASCII
character format ?
I tried with sprintf(). It works.
Is there any other way to do that ?
Objective::
I like to convert an integer value of 3 and write into a string buffer.
#include <stdio.h>
/* ---------------------- */
static void putdecimal(unsigned int v, char **s) {
if (v / 10) putdecimal(v/10, s);
*(*s)++ = (v % 10) + '0';
**s = '\0';
} /* putdecimal */
/* ---------------------- */
int main(void) {
char a[80];
char *t, *s = a;
t = s; putdecimal( 0, &t); puts(s);
t = s; putdecimal( 1, &t); puts(s);
t = s; putdecimal(-1, &t); puts(s);
t = s; putdecimal( 2, &t); puts(s);
t = s; putdecimal(23, &t); puts(s);
t = s; putdecimal(27, &t); puts(s);
return 0;
} /* main */
--
"If you want to post a followup via groups.google.com, don't use
the broken "Reply" link at the bottom of the article. Click on
"show options" at the top of the article, then click on the
"Reply" at the bottom of the article headers." - Keith Thompson
More details at: <http://cfaj.freeshell.org/google/>
Also see <http://www.safalra.com/special/googlegroupsreply/>