Re: itoa

From: Brian (borlick@mines.edu)
Date: 04/07/02


Greetings,
        Not being aware entirely of the prototype of itoa(), it's difficult to
give you an exact answer.  It would help if you had quoted some code
which utilized the function.  After some research, it appears Visual C++
defines the function:

char *itoa( int value, char *string, int radix );

        Assuming you are using base (radix) 10, your code probably looks
something like:

void someFunc(int someNum)
{
   char numStringsz[250];
   itoa(someNum, numStringsz, 10);
   /* ... */
}

        If you are indeed using base 10, you could simply change this to

void someFunc(int someNum)
{
   char numStringsz[250];
   sprintf(numStringsz, "%d", someNum);
   /* ... */
}

        If you are using base 8, or 16, use %o (octal, base 8) or %x
(hexadecimal, base 16) in place of %d.
        For the actual algorithm of printing in any base, try
http://www.cs.fiu.edu/~weiss/dsj/errata/180.pdf or just search Google.

Kras Kresh wrote:
>
> I need that function, [itoa] but my server doesn't seem to support it, unless there

--
   +---------------------------------------------------------------+
   | FAQ: http://qsilver.queensu.ca/~fletchra/Circle/list-faq.html |
   | Archives: http://post.queensu.ca/listserv/wwwarch/circle.html |
   | Newbie List:  http://groups.yahoo.com/group/circle-newbies/   |
   +---------------------------------------------------------------+



This archive was generated by hypermail 2b30 : 06/25/03 PDT