This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: converting int to string
- From: Eljay Love-Jensen <eljay at adobe dot com>
- To: Colin Law <c dot law at elec dot gla dot ac dot uk>, gcc-help at gcc dot gnu dot org
- Date: Mon, 25 Nov 2002 07:06:56 -0600
- Subject: Re: converting int to string
Hi Colin,
>Sorry, if this is a rather easy one, but can someone tell me how to
convert an int, or any other value ,into a string?
Whew, an easy one!
--- Append.h ---
#include <string>
// Appends the value onto the end of the given string.
// Adds a space inbetween them.
void Append(std::string& ioString, int inValue);
--- End Append.h ---
--- Append.cpp ---
#include "Append.h"
#include <string>
#include <sstream>
void Append(std::string& ioString, int inValue) {
std::ostringstream o;
o << ioString << " " << inValue;
ioString = o.str();
}
--- End Append.cpp ---
Ta-dah!
--Eljay