Re: undefined 'lseek' whem converting CW8->CW9



On 20.07.2005 23:33, in article
1121888024.908730.135530@xxxxxxxxxxxxxxxxxxxxxxxxxxxx, "brianhray@xxxxxxxxx"
<brianhray@xxxxxxxxx> wrote:

> char * itoa(unsigned n, char *s, int rad)
> {
> #pragma unused(rad) // taken care of by sprintf
> sprintf(s, "%d", n);
> return s;
> }
>
> But I am unsure that the radix is actually being taken care of my
> sprintf.

Here, the radix is always 10 (I'd put an assert() instead of the pragma).
For octal and hexadecimal, there are %o and %x.

> Did you say these are available in libc?

What I meant was that unless you need something other than octal, decimal
and hexadecimal, you can replace all instances of itoa with equivalent
sprintf's. Completely reimplementing itoa in terms of standard C/C++ is
slightly harder (I made a quick Google search, and found an example here
<http://www.daniweb.com/techtalkforums/threadedpost54281.html>).

I do not know any reason why C/C++/POSIX do not have itoa, given that
strtol is standard, and supports various bases. Perhaps I'm missing
something...

- WBR, Alexey Proskuryakov

.



Relevant Pages

  • Re: undefined lseek whem converting CW8->CW9
    ... Some implementations, e.g. ... By the way I don't think sprintf support other than decimal output and of course hex for %p. ... #pragma unused// taken care of by sprintf ...
    (comp.sys.mac.programmer.codewarrior)
  • Re: undefined lseek whem converting CW8->CW9
    ... #pragma unused// taken care of by sprintf ... char * uitoa(unsigned n, char *s, int rad) ...
    (comp.sys.mac.programmer.codewarrior)
  • CC51 compile error with MPLAB
    ... I am trying to resolve a compile-time error using CC5x through MPLab. ... I have a code project (SOURCE CODE AT BOTTOM) where I'm trying to ... char digit,daten; ... #pragma config_def 0x0111 ...
    (comp.arch.embedded)
  • Re: Its A Start
    ... Thanks Char (and everyone else, ... I intend to, and I should have listed it as one of the things I intend ... of this writing, I have yet to receive benefits from blah, blah, blah - ... and home care nurses to take care of things once ...
    (alt.med.fibromyalgia)
  • Re: somebody dropped a (warning) bomb
    ... But THE CALLER CANNOT AND MUST NOT CARE! ... Because the sign of "char" is ... warning sounds obviously insane. ... Make even "int" arguments (which ...
    (Linux-Kernel)