Go to Post As guests in the city, we should make an effort to do some fundraising for the folks affected by the storm. Any ideas out there? - Jon236 [more]
Home
Go Back   Chief Delphi > Technical > Programming
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
 
 
Thread Tools Rate Thread Display Modes
Prev Previous Post   Next Post Next
  #4   Spotlight this post!  
Unread 19-01-2003, 16:22
Zmeko Zmeko is offline
Registered User
no team
 
Join Date: Jan 2003
Location: Freehold Iowa
Posts: 15
Zmeko is an unknown quantity at this point
ITOA code from the CRT:
PHP Code:
static void __cdecl xtoa (
        
unsigned long val,
        
char *buf,
        
unsigned radix,
        
int is_neg
        
)
{
        
char *p;                /* pointer to traverse string */
        
char *firstdig;         /* pointer to first digit */
        
char temp;              /* temp char */
        
unsigned digval;        /* value of digit */

        
buf;

        if (
is_neg) {
            
/* negative, so output '-' and negate */
            
*p++ = '-';
            
val = (unsigned long)(-(long)val);
        }

        
firstdig p;           /* save pointer to first digit */

        
do {
            
digval = (unsigned) (val radix);
            
val /= radix;       /* get next digit */

            /* convert to ascii and store */
            
if (digval 9)
                *
p++ = (char) (digval 10 'a');  /* a letter */
            
else
                *
p++ = (char) (digval '0');       /* a digit */
        
} while (val 0);

        
/* We now have the digit of the number in the buffer, but in reverse
           order.  Thus we reverse them now. */

        
*p-- = '\0';            /* terminate string; p points to last digit */

        
do {
            
temp = *p;
            *
= *firstdig;
            *
firstdig temp;   /* swap *p and *firstdig */
            
--p;
            ++
firstdig;         /* advance to next two digits */
        
} while (firstdig p); /* repeat until halfway */

http://www.cplusplus.com/ref/cstdlib/fcvt.html


Quote:
Kind of annoying that two very similar functions have such a different syntax
itoa cant convert a double to a string, fcvt can.

Anyways, Adam Shapiro, visit http://www.cplusplus.com/ref/. it contains information about functions in the standard c library and iostream.
i think in the future they might cover STL but you can always visit the STL docs for information: http://www.sgi.com/tech/stl/stl_index.html
 


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -5. The time now is 17:36.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi