Hi all,

I'm working with some date formating, with local and UTC time format. At the end I've print the result to the console as follows.

cout << stLocal.wMonth << "/" << stLocal.wDay << "/" << stLocal.wYear << " " << stLocal.wHour << ":" << stLocal.wMinute << "\n";

This line of code works fine, but seems this is too dull when passing this time. Actually I want to pass that value as a string(as a single value) and try the following.

ostringstream os;
		os << stLocal.wMonth << "/" << stLocal.wDay << "/" << stLocal.wYear << " " << stLocal.wHour << ":" << stLocal.wMinute << "\t";
		cout << os;//0012FA3C

The thing here the output is just a number, 0012FA3C for all values.

What's wrong with my code.

change cout << os ; to cout << os.str() ;
os.str() gets the string from the stringstream.
cout << os ; is equivalent to cout << (const void*)os ; prints the pointer value.

This question has already been answered. Start a new discussion instead.