making the code look nice

I am done with my code. All I need to do now is make it so when single digits in the countdown come up, there is a space in front of them. For example:
10
(space) 9
etc...to 0.

Here is the code:


#include <iomanip>
#include <iostream>
using namespace std;

#include <windows.h>
#include <cstdlib>


int main ()
{
cout << "CTRL-C to exit....\n";
for (int units = 10; units >= 0; units--)
{
cout << units << ' ';
cout.flush();
Sleep(1);

_sleep (1000);

cout << '\r';


}
return 0;
}

Thanks in advance!
Last edited on
closed account (iLUjLyTq)
cout << setw(2) << units <<' ';
Thanks! I am going to mark this as solved, but if you could point me to a link or explain where setw comes from, that would be appreciated. Thanks again.
closed account (iLUjLyTq)
http://cplusplus.com/reference/iostream/manipulators/ here it is
Topic archived. No new replies allowed.