Formatting numbers in loop

Posted by dave9909 on Stack Overflow See other posts from Stack Overflow or by dave9909
Published on 2010-05-24T07:29:39Z Indexed on 2010/05/24 7:41 UTC
Read the original article Hit count: 222

Filed under:
|
|
|

I want to list all numbers from 0000-9999 however I am having trouble holding the zero places.

I tried:

for(int i = 0; i <= 9999; ++i)
{
cout << i << "\n";
}

but I get: 1,2,3,4..ect How can I make it 0001,0002,0003....0010, etc

© Stack Overflow or respective owner

Related posts about c++

Related posts about c