Reputation: 43
In a function i'm passing ostream and wants to convert into a string.
void func (ostream& stream) {
/* Needs to convert stream into string */
}
Upvotes: 1
Views: 701
Reputation: 523
void func (ostream& stream) {
/* Needs to convert stream into string */
std::stringstream ss;
ss << stream.rdbuf();
std::string myString = ss.str();
}
Upvotes: 6