Where do I get documentation on all this? When I search the msdn library
char str[] types. What function do I need to use to get the length of a
"Daniel" <Mahonri@cableone.net> ha scritto nel messaggio
news:ujc48k4yIHA.2292@TK2MSFTNGP03.phx.gbl...
Now I can't use the _itoa_s function because it requires a char type.
What function could I use to convert an integer value to a std::string
value. I tried to use a cast but it would not work.
You may use code like this:
<code>
#include <string> // string
#include <sstream> // ostringstream
// Convert int to STL string
std::string ToString( int n )
{
std::ostringstream os;
os << n;
return os.str();
}
</code>
and use like this:
std::string s = ToString( 10 );
Or you may use an implementation based on C sprintf:
<code>
// Convert int to STL string
std::string ToString( int n )
{
char buf[ 100 ]; // Big enough buffer
sprintf( buf, "%d", n );
return std::string( buf );
}
</code>
HTH,
Giovanni