Small question on displaying ints

Dec 3, 2008 at 12:58am
Say I have the user input a zipcode, and it turns out to be something like 00020. And then I want to display it to the user. How do I have it so that it displays 00020 and not 20?
Dec 3, 2008 at 1:52am
you would be better off declaring it as a char, your other option would be to use an int array to hold each value individually. but a char makes the most sense for a zip code.
Dec 3, 2008 at 1:56am
cout << setw( 5 ) << setfill( '0' ) << zipcode;

Topic archived. No new replies allowed.