/* DemoFormattedIO2.cpp CIS 150 6/3/2008 David Klick This program demonstrates the use of setfill(char). */ #include #include using std::cout; using std::endl; using std::cin; using std::setw; using std::setfill; void cont(); int main(void) { int num = 0; cout << "Enter an integer: "; cin >> num; cout << "You entered " << setfill('0') << setw(6) << num << endl; cont(); return 0; } void cont() { if (cin.rdbuf()->sungetc() != -1 && cin.get() != '\n') cin.ignore(80,'\n'); cout << "Press enter to continue..."; cin.get(); } /* Sample output: Enter an integer: 67 You entered 000067 */