ostream


1. Basic Output

#include <iostream>

using namespace std;

int main() {
  cout << "Hello, world!" << endl;
  return 0;
}

2. Formatted Output

#include <iostream>
#include <iomanip>

using namespace std;

int main() {
  cout << fixed << setprecision(2);
  cout << "Pi is approximately " << 3.14159265 << endl;
  return 0;
}

3. Output to a File

4. Output Redirection

5. Output Filtering

6. Output Custom Formatting

7. Output Manipulators

8. Output to a String

9. Output to a Buffer

10. Output to a Stream Buffer

11. Output to a File and Console

12. Output to a Vector

13. Output to a List

14. Output to a Deque

15. Output to a Set

16. Output to a Map

17. Output to a Tuple

18. Output to a Pair

19. Output to a File with Append

20. Output to a File with Truncate

21. Output to a File with Binary Mode