Is istream or ostream "object" assignable?

Let's say there's an expression like:
1
2
3
4
5
6
7
8
#include<iostream>
#include<iomanip>
int main()
{
int a(78);
//to get the hexadecimal equivalent we can have
std::cout<<std::hex<<a<<std::endl;
//the result would be 4e. 

Ok good, now my question is, Instead of std::cout-ing the result, is it possible to assign the result to either a char or string variable?
You can use a stringstream, which is a string that can be treated as a stream (like cout). Then use .str() to get the string out of it.
Topic archived. No new replies allowed.