# **[](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. ## Example 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 #include 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; } ```