skip to content
Ivan's wiki
Site Tools
Search
Tools
Show pagesource
Backlinks
Recent Changes
Media Manager
Sitemap
>
Recent Changes
Media Manager
Sitemap
hpp-iomanip
This page is read only. You can view the source, but not change it.
# <iomanip> **[<iomanip>](https://en.cppreference.com/w/cpp/header/iomanip)** provides stream manipulators for formatting output: `std::setw`, `std::setprecision`, `std::setfill`, `std::hex`, `std::oct`, `std::fixed`, `std::scientific`. They temporarily modify the stream state for a single output operation. Most modern code prefers `std::format`, but `iomanip` remains useful for legacy streams. This example applies various formatting manipulators to control decimal precision, hexadecimal output, and field width. ```cpp // compile: g++ -std=c++11 -o iomanipexample iomanipexample.cpp // run: ./iomanipexample // description: stream formatting with manipulators #include <iomanip> #include <iostream> int main() { double pi = 3.14159; int value = 255; std::cout << std::fixed << std::setprecision(2) << pi << "\n"; std::cout << std::hex << value << "\n"; std::cout << std::setw(10) << std::setfill('*') << 42 << "\n"; return 0; } ```
Page Tools
Show pagesource
Backlinks
Back to top