This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Lexical conversion.


>>>>> "John" == John Carter <john.carter@tait.co.nz> writes:

    John> What is the fastest way under gcc-3.* to convert from an int
    John> to a string?  ie. Equivalent to this yucky bit of code...

We are talking about C++, right? I don't know how fast it is (or what
your constrains are), but I would use something like that:

#include <sstream>

string convert (const int number) {
     ostringstream ostr;
     ostr << number;
     return ostr.str ();
}

-- 
Claudio Bley                                 ASCII ribbon campaign (")
Debian GNU/Linux advocate                     - against HTML email  X 
http://www.cs.uni-magdeburg.de/~bley/                     & vCards / \


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]