Lexical conversion.

Claudio Bley bley@cs.uni-magdeburg.de
Tue Oct 15 01:50:00 GMT 2002


>>>>> "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 / \



More information about the Gcc-help mailing list