bug-lib-gplusplus
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: itoa implementation


From: Greg Chicares
Subject: Re: itoa implementation
Date: Wed, 04 Jul 2001 00:20:50 -0400

Peter Enseleit wrote:
> 
> I have found that there is no itoa function to convert an integer to ascii
> in libstdc++ yet.

Perhaps there never will be. It's a nonstandard extension.
This isn't a bug.

> In the meantime can anyone suggest another way of doing the same thing - ie:

Try sprintf() .

> converting a simple integer to ascii for writing to file.

If you just want to write a formatted integer to a file,
use iostreams: then it's as easy as
  my_stream << my_integer;

> I have tried casting with (char*), reinterpret_cast<char*>() etc and these
> compile fine but, they all give me runtime segmentation faults errors.

Well, (char*)0 points to address zero, which is unlikely
to contain the character '0', but is likely to be memory
that your program doesn't own, hence the segfault.

> I am a fairly inexperienced coder

The alt.comp.lang.learn.c-c++ newsgroup is one good place to learn.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]