Hi all, I'm using the itoa function in my C code but it does not
compile in Linux 2.4 (Redhat). I have stdilb.h included. I thought itoa
is part of the standard C library, but on doing a "man itoa" it tells
me no such man entry exists. But I could find atoi as part of the
library. Does that mean I need to implement the itoa function? Is there
any other way?
Thank you.
|
|
0
|
|
|
|
Reply
|
pinaki_m77 (96)
|
10/28/2005 8:39:38 PM |
|
googler wrote:
> Hi all, I'm using the itoa function in my C code but it does not
> compile in Linux 2.4 (Redhat). I have stdilb.h included. I thought itoa
> is part of the standard C library, but on doing a "man itoa" it tells
> me no such man entry exists. But I could find atoi as part of the
> library. Does that mean I need to implement the itoa function? Is there
> any other way?
>
> Thank you.
>
Try the following:
char number[32];
snprintf(number, 32, "%d", integer_value);
--
Fletcher Glenn
|
|
0
|
|
|
|
Reply
|
Fletcher
|
10/28/2005 8:51:10 PM
|
|
itoa() is not part of the C standard library. You need to include
extension.h.
|
|
0
|
|
|
|
Reply
|
David
|
10/29/2005 3:12:51 AM
|
|
"David Shin" <David.W.Shin@gmail.com> writes:
> itoa() is not part of the C standard library. You need to include
> extension.h.
There is no extension.h header on any Linux system I'm aware of.
--
Keith Thompson (The_Other_Keith) kst-u@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this.
|
|
0
|
|
|
|
Reply
|
Keith
|
10/30/2005 10:37:12 AM
|
|
"googler" <pinaki_m77@yahoo.com> schreef in bericht
news:1130531978.715232.34760@g49g2000cwa.googlegroups.com...
> Hi all, I'm using the itoa function in my C code but it does not
> compile in Linux 2.4 (Redhat). I have stdilb.h included. I thought itoa
> is part of the standard C library, but on doing a "man itoa" it tells
> me no such man entry exists. But I could find atoi as part of the
> library. Does that mean I need to implement the itoa function? Is there
> any other way?
>
> Thank you.
>
use stringstream instead
string MyClass::Int2Asc(int intval)
{
stringstream s
s << intval;
return s.str();
}
John
|
|
0
|
|
|
|
Reply
|
Bruintje
|
10/30/2005 5:03:03 PM
|
|
"Bruintje Beer" <me@knoware.nl> said:
>"googler" <pinaki_m77@yahoo.com> schreef in bericht
>news:1130531978.715232.34760@g49g2000cwa.googlegroups.com...
>> Hi all, I'm using the itoa function in my C code but it does not
>> compile in Linux 2.4 (Redhat). I have stdilb.h included.
>
>use stringstream instead
>
>string MyClass::Int2Asc(int intval)
....
Note; the original article discussed C code, not C++. The two languages
are different.
--
Wolf a.k.a. Juha Laiho Espoo, Finland
(GC 3.0) GIT d- s+: a C++ ULSH++++$ P++@ L+++ E- W+$@ N++ !K w !O !M V
PS(+) PE Y+ PGP(+) t- 5 !X R !tv b+ !DI D G e+ h---- r+++ y++++
"...cancel my subscription to the resurrection!" (Jim Morrison)
|
|
0
|
|
|
|
Reply
|
Juha
|
10/30/2005 5:31:42 PM
|
|
"Juha Laiho" <Juha.Laiho@iki.fi> schreef in bericht
news:dk301u$ur8$1@ichaos.ichaos-int...
> "Bruintje Beer" <me@knoware.nl> said:
>>"googler" <pinaki_m77@yahoo.com> schreef in bericht
>>news:1130531978.715232.34760@g49g2000cwa.googlegroups.com...
>>> Hi all, I'm using the itoa function in my C code but it does not
>>> compile in Linux 2.4 (Redhat). I have stdilb.h included.
>>
>>use stringstream instead
>>
>>string MyClass::Int2Asc(int intval)
> ...
>
> Note; the original article discussed C code, not C++. The two languages
> are different.
> --
> Wolf a.k.a. Juha Laiho Espoo, Finland
> (GC 3.0) GIT d- s+: a C++ ULSH++++$ P++@ L+++ E- W+$@ N++ !K w !O !M V
> PS(+) PE Y+ PGP(+) t- 5 !X R !tv b+ !DI D G e+ h---- r+++ y++++
> "...cancel my subscription to the resurrection!" (Jim Morrison)
you can use c++ compiler to compile c programs and have the advantage of c++
string classes
john
|
|
0
|
|
|
|
Reply
|
Bruintje
|
11/5/2005 7:19:29 AM
|
|
"Bruintje Beer" <me@knoware.nl> wrote:
>
>you can use c++ compiler to compile c programs and have the advantage of c++
>string classes
C and C++ are two distinctly different languages, which have a
common subset. If you compile it with a C++ compiler, it isn't
C.
--
FloydL. Davidson http://www.apaflo.com/floyd_davidson
Ukpeagvik (Barrow, Alaska) floyd@apaflo.com
|
|
0
|
|
|
|
Reply
|
Floyd
|
11/5/2005 9:24:35 AM
|
|
"Bruintje Beer" <me@knoware.nl> said:
>"Juha Laiho" <Juha.Laiho@iki.fi> schreef in bericht
>news:dk301u$ur8$1@ichaos.ichaos-int...
>> "Bruintje Beer" <me@knoware.nl> said:
>>>"googler" <pinaki_m77@yahoo.com> schreef in bericht
>>>news:1130531978.715232.34760@g49g2000cwa.googlegroups.com...
>>>> Hi all, I'm using the itoa function in my C code but it does not
>>>> compile in Linux 2.4 (Redhat). I have stdilb.h included.
>>>
>>>use stringstream instead
>>>
>>>string MyClass::Int2Asc(int intval)
>> ...
>>
>> Note; the original article discussed C code, not C++. The two languages
>> are different.
>
>you can use c++ compiler to compile c programs and have the advantage of c++
>string classes
... at which point the code is no longer C (you can't compile it with a C
compiler). There is a case where a completely valid ANSI C program doesn't
go through a C++ compiler:
#include <stdio.h>
#include <stdlib.h>
int
main(int argc, char **argv) {
printf("%d\n",10//*foo*/2);
exit(0);
}
--
Wolf a.k.a. Juha Laiho Espoo, Finland
(GC 3.0) GIT d- s+: a C++ ULSH++++$ P++@ L+++ E- W+$@ N++ !K w !O !M V
PS(+) PE Y+ PGP(+) t- 5 !X R !tv b+ !DI D G e+ h---- r+++ y++++
"...cancel my subscription to the resurrection!" (Jim Morrison)
|
|
0
|
|
|
|
Reply
|
Juha
|
11/6/2005 8:54:30 AM
|
|
Juha Laiho <Juha.Laiho@iki.fi> writes:
>"Bruintje Beer" <me@knoware.nl> said:
>>"Juha Laiho" <Juha.Laiho@iki.fi> schreef in bericht
>>news:dk301u$ur8$1@ichaos.ichaos-int...
>>> "Bruintje Beer" <me@knoware.nl> said:
>>>>"googler" <pinaki_m77@yahoo.com> schreef in bericht
>>>>news:1130531978.715232.34760@g49g2000cwa.googlegroups.com...
>>>>> Hi all, I'm using the itoa function in my C code but it does not
>>>>> compile in Linux 2.4 (Redhat). I have stdilb.h included.
>>>>
>>>>use stringstream instead
>>>>
>>>>string MyClass::Int2Asc(int intval)
>>> ...
>>>
>>> Note; the original article discussed C code, not C++. The two languages
>>> are different.
>>
>>you can use c++ compiler to compile c programs and have the advantage of c++
>>string classes
>.. at which point the code is no longer C (you can't compile it with a C
>compiler). There is a case where a completely valid ANSI C program doesn't
>go through a C++ compiler:
>#include <stdio.h>
>#include <stdlib.h>
>int
>main(int argc, char **argv) {
> printf("%d\n",10//*foo*/2);
> exit(0);
>}
Is this still valid C99?
Casper
--
Expressed in this posting are my opinions. They are in no way related
to opinions held by my employer, Sun Microsystems.
Statements on Sun products included here are not gospel and may
be fiction rather than truth.
|
|
0
|
|
|
|
Reply
|
Casper
|
11/6/2005 9:37:38 AM
|
|
M�ns Rullg�rd wrote:
> Casper H.S. Dik <Casper.Dik@Sun.COM> writes:
>
>
>>Juha Laiho <Juha.Laiho@iki.fi> writes:
>>
>>
>>>"Bruintje Beer" <me@knoware.nl> said:
>>>
>>>>"Juha Laiho" <Juha.Laiho@iki.fi> schreef in bericht
>>>>news:dk301u$ur8$1@ichaos.ichaos-int...
>>>>
>>>>>"Bruintje Beer" <me@knoware.nl> said:
>>>>>
>>>>>>"googler" <pinaki_m77@yahoo.com> schreef in bericht
>>>>>>news:1130531978.715232.34760@g49g2000cwa.googlegroups.com...
>>>>>>
>>>>>>>Hi all, I'm using the itoa function in my C code but it does not
>>>>>>>compile in Linux 2.4 (Redhat). I have stdilb.h included.
>>>>>>
>>>>>>use stringstream instead
>>>>>>
>>>>>>string MyClass::Int2Asc(int intval)
>>>>>
>>>>>...
>>>>>
>>>>>Note; the original article discussed C code, not C++. The two languages
>>>>>are different.
>>>>
>>>>you can use c++ compiler to compile c programs and have the
>>>>advantage of c++ string classes
>>
>>>.. at which point the code is no longer C (you can't compile it with a C
>>>compiler). There is a case where a completely valid ANSI C program doesn't
>>>go through a C++ compiler:
>>
>>>#include <stdio.h>
>>>#include <stdlib.h>
>>
>>>int
>>>main(int argc, char **argv) {
>>> printf("%d\n",10//*foo*/2);
>>> exit(0);
>>>}
>>
>>Is this still valid C99?
>
>
> This is valid C99, but not C++:
>
> int
> main(int argc, char **argv)
> {
> int class = 17;
> return 0;
> }
>
There's more subtle differences as well.
struct foo {
int a;
int b;
};
int
main(int argc, char **argv)
{
int foo = 42;
printf("%u\n",(unsigned)sizeof(foo));
return 0;
}
|
|
0
|
|
|
|
Reply
|
ISO
|
11/6/2005 2:55:21 PM
|
|
Casper H.S. Dik <Casper.Dik@Sun.COM> writes:
> Juha Laiho <Juha.Laiho@iki.fi> writes:
>
>>"Bruintje Beer" <me@knoware.nl> said:
>>>"Juha Laiho" <Juha.Laiho@iki.fi> schreef in bericht
>>>news:dk301u$ur8$1@ichaos.ichaos-int...
>>>> "Bruintje Beer" <me@knoware.nl> said:
>>>>>"googler" <pinaki_m77@yahoo.com> schreef in bericht
>>>>>news:1130531978.715232.34760@g49g2000cwa.googlegroups.com...
>>>>>> Hi all, I'm using the itoa function in my C code but it does not
>>>>>> compile in Linux 2.4 (Redhat). I have stdilb.h included.
>>>>>
>>>>>use stringstream instead
>>>>>
>>>>>string MyClass::Int2Asc(int intval)
>>>> ...
>>>>
>>>> Note; the original article discussed C code, not C++. The two languages
>>>> are different.
>>>
>>>you can use c++ compiler to compile c programs and have the
>>>advantage of c++ string classes
>
>>.. at which point the code is no longer C (you can't compile it with a C
>>compiler). There is a case where a completely valid ANSI C program doesn't
>>go through a C++ compiler:
>
>>#include <stdio.h>
>>#include <stdlib.h>
>
>>int
>>main(int argc, char **argv) {
>> printf("%d\n",10//*foo*/2);
>> exit(0);
>>}
>
> Is this still valid C99?
This is valid C99, but not C++:
int
main(int argc, char **argv)
{
int class = 17;
return 0;
}
--
M�ns Rullg�rd
mru@inprovide.com
|
|
0
|
|
|
|
Reply
|
iso
|
11/6/2005 3:06:38 PM
|
|
"Nils O. Sel�sdal" <noselasd@asgaard.homelinux.org> writes:
> M�ns Rullg�rd wrote:
>> Casper H.S. Dik <Casper.Dik@Sun.COM> writes:
>>
>>>>.. at which point the code is no longer C (you can't compile it with a C
>>>>compiler). There is a case where a completely valid ANSI C program doesn't
>>>>go through a C++ compiler:
>>>
>>>>#include <stdio.h>
>>>>#include <stdlib.h>
>>>
>>>>int
>>>>main(int argc, char **argv) {
>>>> printf("%d\n",10//*foo*/2);
>>>> exit(0);
>>>>}
>>>
>>>Is this still valid C99?
>> This is valid C99, but not C++:
>> int
>> main(int argc, char **argv)
>> {
>> int class = 17;
>> return 0;
>> }
>>
> There's more subtle differences as well.
>
> struct foo {
> int a;
> int b;
> };
>
> int
> main(int argc, char **argv)
> {
> int foo = 42;
> printf("%u\n",(unsigned)sizeof(foo));
> return 0;
> }
>
That prints 4 in both cases.
--
M�ns Rullg�rd
mru@inprovide.com
|
|
0
|
|
|
|
Reply
|
iso
|
11/6/2005 4:16:02 PM
|
|
M�ns Rullg�rd wrote:
>>There's more subtle differences as well.
>>
>>struct foo {
>> int a;
>> int b;
>>};
>>
>>int
>>main(int argc, char **argv)
>>{
>> int foo = 42;
>> printf("%u\n",(unsigned)sizeof(foo));
>> return 0;
>>}
>>
>
>
> That prints 4 in both cases.
>
Silly me, make that
#include <stdio.h>
int foo = 42;
int
main(int argc, char **argv)
{
struct foo { int a; int b; };
printf("%u\n",(unsigned)sizeof(foo));
return 0;
}
|
|
0
|
|
|
|
Reply
|
ISO
|
11/7/2005 2:54:39 PM
|
|
"Nils O. Sel�sdal" <noselasd@asgaard.homelinux.org> writes:
> M�ns Rullg�rd wrote:
>
>>>There's more subtle differences as well.
>>>
>>>struct foo {
>>> int a;
>>> int b;
>>>};
>>>
>>>int
>>>main(int argc, char **argv)
>>>{
>>> int foo = 42;
>>> printf("%u\n",(unsigned)sizeof(foo));
>>> return 0;
>>>}
>>>
>> That prints 4 in both cases.
>>
>
> Silly me, make that
>
> #include <stdio.h>
>
> int foo = 42;
> int
> main(int argc, char **argv)
> {
> struct foo { int a; int b; };
> printf("%u\n",(unsigned)sizeof(foo));
> return 0;
> }
Yep, that prints 4 as C, 8 as C++, just as expected. Isn't this proof
enough that C++ is evil?
--
M�ns Rullg�rd
mru@inprovide.com
|
|
0
|
|
|
|
Reply
|
iso
|
11/7/2005 6:43:00 PM
|
|
|
14 Replies
1756 Views
(page loaded in 0.159 seconds)
Similiar Articles: itoa() in Linux - comp.unix.programmerHi all, I'm using the itoa function in my C code but it does not compile in Linux 2.4 (Redhat). I have stdilb.h included. I thought itoa is part of th... What is the industry standard for number of servers per Unix/Linux ...itoa() in Linux - comp.unix.programmer So, yes, itoa should use the locale as well, in |> a way that should be recognized ... What is the industry standard for number of ... Converting number to std::string ("itoa()" ) - comp.lang.c++ ...itoa() in Linux - comp.unix.programmer Converting number to std::string ("itoa()" ) - comp.lang.c++ ... So, yes, itoa should use the locale as well, in |> a way that ... integer overflow in atoi - comp.lang.citoa() in Linux - comp.unix.programmer But I could find atoi as part of the library. Does ... char number[32]; snprintf(number, 32, "%d", integer ... Problem of debugging into glibc functions? - comp.unix.programmer ...Hi all, I want to debug into glibc functions like nftw() in Ubuntu Linux (nftw ... Converting number to std::string ("itoa()" ) - comp.lang.c++ ... The problem of the ... show numeric (octal) representation of permissions - comp.unix ...Converting number to std::string ("itoa()" ) - comp.lang.c++ ... ... this over ... Notation UNIX / Linux Command Chmod Numeric Permissions Notation UNIX / Linux Command ... Convert month name to month number faster - comp.lang.python ...I'm using python 2.6 on linux x64. month_dict =3D {"Jan":1,"Feb":2,"Mar":3,"Apr ... Converting number to std::string ("itoa()" ) - comp.lang.c++ ... Hello, What would ... cannot set locale correctly - comp.unix.solarisConverting number to std::string ("itoa()" ) - comp.lang.c++ ... Only for the ten ... Couldn't set locale correctly - The UNIX and Linux Forums Hello, I have a recently ... PROJECT IDEAS - comp.unix.programmer- -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.5 (GNU/Linux) Comment: Processed by ... Converting number to std::string ("itoa()" ) - comp.lang.c++ ...-- Francis ... Long integer to string conversions - comp.sys.hp.hpux... following functions, > ltostr(),ultostr(),ltoa(),ultoa(),ioctl() because my > linux ... Converting number to std::string ("itoa()" ) - comp.lang.c++ ... Long integer to ... std::map clear throws an exception - comp.lang.c++.moderated ...Converting number to std::string ("itoa()" ) - comp.lang.c++ ... converting double to ... ACE_OS::munmap() throws exception in suse linux 64 bit - comp.soft ... [ace-users] No ... utc to local time conversion with dst considered? - comp.soft-sys ...Converting number to std::string ("itoa()" ) - comp.lang.c++ ... One implement such a ... New to NTP on Linux - comp.protocols.time.ntp... that the Motorola Oncore is ... Way to avoid having to type sudo password each time? - comp.sys ...Converting number to std::string ("itoa()" ) - comp.lang.c++ ... Hello, What would ... Avoid typing sudo on Ubuntu Linux - nixCraft: Linux Tips, Hacks ... Avoid typing sudo ... counting the digits in a number, exponential format problem - comp ...> > it appears as though PHP might use something similar to the Linux > function strtod ... Converting number to std::string ("itoa()" ) - comp.lang.c++ ..... eg. by looping ... c - Where is the itoa function in Linux? - Stack Overflowitoa() is a really handy function to convert a number to a string. Linux does not seem to have itoa(), is there an equivalent function or do I have to use sprintf(str ... itoa with GCC | C/C++ - Jodrell Bank Centre for AstrophysicsHow do I use itoa() with GCC? Arrgghh C/C++! It would appear that itoa() isn't ANSI C standard and doesn't work with GCC on Linux (at least the version I'm using). 7/22/2012 12:20:33 AM
|