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.

Recommended Answers

All 2 Replies

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.

Oh, it's really new thing for me. Thanks pal.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.