J
John Carroll
Does anyone have a function or procedure for converting integers to
character strings?
Thank you,
John
character strings?
Thank you,
John
John said:Does anyone have a function or procedure for converting integers to
character strings?
sprintf() (or better, if you have a [somewhat] C99 compatibleJohn said:Does anyone have a function or procedure for converting integers to
character strings?
Neil said:John Carroll wrote:
> itoa()
HTH,> printf()
Nope.
> sprintf()
Yup!
Nope.
Walter said:Artie Gold said:Nope.
printf() is indeed capable of converting integers to character
strings -- it just has its own ideas about where the character
strings should end up. ;-)
If one cared to go through the bother, one could, completely
within standard C for hosted environments, open a file read/write,
printf() to produce the character string output, rewind to the
beginning of the file, and read the string in to the desired
destination buffer. Sure it'd be clunky, but conformant.
Depending on how many extensions one was willing to live with, there is
even a case in which the operation might be relatively efficient -- if
one closed stdout, nmap()'d some memory, took the fd from that [which
would be the fd normally used for stdout because of the POSIX rules
about using the first available fd], used fdopen() to pull that up to a
FILE*, and used printf() to do the desired conversion, then the result
could be read back directly from the memory area nmap'd to.
Who needs simple standard sprintf() when one can use something
complicated, not generally portable, but 3001 ? ;-)
Walter Roberson wrote: [...]
Hmmm. Seems you're about a week late on this response (at least in my
time zone) ;-) ;-)
[Well, at least it's not "TCP/IP by carrier pigeon"!]
[snip]Walter Roberson wrote: [...]
Hmmm. Seems you're about a week late on this response (at least in my
time zone) ;-) ;-)[Well, at least it's not "TCP/IP by carrier pigeon"!]
?? According to the message headers, the message that started this
thread was posted at Fri, 08 Apr 2005 12:07:41 EDT,
printf() is indeed capable of converting integers to character
strings -- it just has its own ideas about where the character
strings should end up. ;-)
If one cared to go through the bother, one could, completely
within standard C for hosted environments, open a file read/write,
printf() to produce the character string output, rewind to the
beginning of the file, and read the string in to the desired
destination buffer. Sure it'd be clunky, but conformant.
Depending on how many extensions one was willing to live with, there is
even a case in which the operation might be relatively efficient -- if
one closed stdout, nmap()'d some memory, took the fd from that [which
would be the fd normally used for stdout because of the POSIX rules
about using the first available fd], used fdopen() to pull that up to a
FILE*,
and used printf() to do the desired conversion, then the result
could be read back directly from the memory area nmap'd to.
Who needs simple standard sprintf() when one can use something
complicated, not generally portable, but 3001 ? ;-)
#include <stdio.h>John said:Does anyone have a function or procedure for converting integers to
character strings?
Thank you,
John
If one cared to go through the bother, one could, completely
within standard C for hosted environments, open a file read/write,
printf() to produce the character string output, rewind to the
beginning of the file, and read the string in to the desired
destination buffer. Sure it'd be clunky, but conformant.
Artie said:Neil said:John Carroll wrote:
[top posting orrected]
itoa()
No such thing.
HTH,printf()
Nope.
Yup!
--ag
Neil said:Artie said:Neil said:John Carroll wrote:
Does anyone have a function or procedure for converting integers
to character strings?
[top posting orrected]
itoa()
No such thing.
printf()
Nope.
sprintf()
Yup!
itoa() exists, I assume it is non-standard??
Neil Kurzman said:Artie Gold wrote: [...]No such thing.
itoa() exists, I assume it is non-standard??
I listed printf() because what do you do with a string. fprintf() would
be the other destination.
itoa() exists, I assume it is non-standard??
itoa() exists, I assume it is non-standard??
Neil Kurzman wrote on 11/04/05 :
If it not standard, it doesn't exist
Chris Croughton said:Of course itoa() exists on many systems and in many program sources. It
simply isn't On Topic for this newsgroup, and can't be used portably.
That's one of the stupid attitudes which encourages people to label
comp.lang.c as a bunch of ego-wankers.
Of course itoa() exists on many systems and in many program sources. It
simply isn't On Topic for this newsgroup, and can't be used portably.
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.