Quantcast
Channel: Int to String conversion
Viewing all articles
Browse latest Browse all 2

Int to String conversion

$
0
0
Here is my code:

template<class T> void ToString(T &var, string &rhs)
{
stringstream conv;

conv << var;
conv.str(rhs);
};

I made a simple template function which I thought would do a nice integer or any applicable variable to string conversion.  When I call it:

int main(int argc, char *argv[])
{
string buffer;
int Day(0);

ToString<int>(Day,buffer);

cout << "The day is " << buffer;

return 0;
}

The output is

The day is

What am I doing wrong?

Viewing all articles
Browse latest Browse all 2

Latest Images

Trending Articles



Latest Images