Hi,
I am used to the itoa function in Watcom C compiler. Looks like there is
no equivalent in gcc in Linux.
Does any one know a shorter way to do 'itoa' 'ltoa' 'ftoa' etc.
Please Help!
Suresh.S
I am used to the itoa function in Watcom C compiler. Looks like there is
no equivalent in gcc in Linux.
Does any one know a shorter way to do 'itoa' 'ltoa' 'ftoa' etc.
Please Help!
Suresh.S
: Does any one know a shorter way to do 'itoa' 'ltoa' 'ftoa' etc.
Have you looked at sprintf(3) ???
ie:
char __print_buffer[1024];
#define itoa(num) sprintf(__print_buffer,"%d",num)
#define ltoa(num) sprintf(__print_buffer,"%d",num)
#define ftoa(num) sprintf(__print_buffer,"%f",num)
--
Copyright 1995 Jason McMullan; all rights reserved; license for the
Microsoft Network to distribute this text for US $100,000 per copy is
hereby granted; all other use of this text by the Microsoft Network,
including storing, relaying, or reuse is expressly prohibited; distribution
by the Microsoft Network indicates full acceptance of the licensing terms.
MICKEY# 4729-304-8732
>: Does any one know a shorter way to do 'itoa' 'ltoa' 'ftoa' etc.
> Have you looked at sprintf(3) ???
>ie:
>char __print_buffer[1024];
>#define ltoa(num) sprintf(__print_buffer,"%d",num)
Witty .sig under construction.
You didn't ask for C++ but let's just look at it:Quote:sur writes:
> Does any one know a shorter way to do 'itoa' 'ltoa' 'ftoa' etc.
int i;
...
String s = dec(i);
-------------------
ralf
--
PGP: 1024/0xA713ECE9 2047/0xC8E605F5
: : Does any one know a shorter way to do 'itoa' 'ltoa' 'ftoa' etc.
: Have you looked at sprintf(3) ???
: ie:
: char __print_buffer[1024];
Why so big?
: #define itoa(num) sprintf(__print_buffer,"%d",num)
: #define ltoa(num) sprintf(__print_buffer,"%d",num)
: #define ftoa(num) sprintf(__print_buffer,"%f",num)
Mark.
: --
: Copyright 1995 Jason McMullan; all rights reserved; license for the
: Microsoft Network to distribute this text for US $100,000 per copy is
: hereby granted; all other use of this text by the Microsoft Network,
: including storing, relaying, or reuse is expressly prohibited; distribution
: by the Microsoft Network indicates full acceptance of the licensing terms.
: MICKEY# 4729-304-8732
If portability is an issue, you shouldn't rely on the return valueQuote:>char __print_buffer[1024];
>#define itoa(num) sprintf(__print_buffer,"%d",num)
>#define ltoa(num) sprintf(__print_buffer,"%d",num)
>#define ftoa(num) sprintf(__print_buffer,"%f",num)
Ali.
1. Gcc support for tchar and itoa()?
Hello,
We are attempting a port from Win32 to Linux.
Under gcc, it appears that there is no support for the tchar data type, nor
for string functions xtoa(), such as itoa(), as they don't appear in any
header files (though they are exported from various libs).
gcc -v gives me:
gcc version egcs-2.91.66 19990314/Linux (egcs-1.1.2 release)
Does GNU simply not support these, or might I have a have a library or
version problem? It is my understanding that these are C Standard items.
Thanks,
Tony S.
2. DirecDuo
7. atoi\itoa
10. itoa - error
13. itoa from DavidK