Stream Formatting with <iomanip>
🟢 Beginner
📖 Definition
The <iomanip> header provides manipulators like std::setw, std::setprecision, std::fixed, and std::setfill to format tabular console output cleanly.
💡 Code Example
#include <iostream>
#include <iomanip>
int main() {
double pi = 3.14159265;
std::cout << std::fixed << std::setprecision(2);
std::cout << "Formatted PI: " << pi << "\n";
return 0;
}
👀 Output
Formatted PI: 3.14