setw and setfill setw sets minimum output width resets to 0 after next output operation setfill sets the fill characters Fill character defaults to space std::cout << std::setw(10) << 123; std::cout << std::setw(5) << std::setfill('#'); std::cout << "hi" << 123; Can also use std::cout.width(10) And std::cout.fill('#')