String Operations - IV
posted under
C program
,
C++ program
,
character arrays
,
string operations
,
strings
by Anonymous
#include <cctype>
#include <string>
#include <cstring>
#include <vector>
#include <iostream>
#include <cstdio>
#include <cstdlib>
std::string toString( bool value )
{
return value?"true":"false";
}
std::string toString( int value )
{
char buffer[ 256 ];
sprintf( buffer, "%d", value );
return buffer;
}
std::string toString( double value )
{
char buffer[ 256 ];
sprintf( buffer, "%lf", value );
return buffer;
}
std::string toString( char value )
{
char buffer[ 2 ];
buffer[0] = value;
buffer[1] = '\0';
return buffer;
}

Comment Form under post in blogger/blogspot