fork download
  1. #include <string>
  2. #include <sstream>
  3. #include <iostream>
  4. #include <iomanip>
  5.  
  6. int main()
  7. {
  8. std::ostringstream oss;
  9.  
  10. oss << "The answer is: ";
  11. oss << 42;
  12. oss << ", and this is a double: ";
  13. oss << 3.14;
  14. oss << ". " << std::endl;
  15. oss << "Oh, btw, you can also output booleans: ";
  16. oss << std::boolalpha << true;
  17. oss << ". See? It's easy!" << std::endl;
  18.  
  19. std::cout << oss.str();
  20. }
Success #stdin #stdout 0s 3028KB
stdin
Standard input is empty
stdout
The answer is: 42, and this is a double: 3.14. 
Oh, btw, you can also output booleans: true. See? It's easy!