Print numbers sequentially using printf with filling zeroes

Posted by Werner on Stack Overflow See other posts from Stack Overflow or by Werner
Published on 2010-06-08T15:56:45Z Indexed on 2010/06/08 16:02 UTC
Read the original article Hit count: 166

Filed under:

Hi,

in C++, using printf I want to print a sequence of number, so I get, from a "for" loop;

1
2
...
9
10
11

and I create files from those numbers. But when I list them using "ls" I get

10
11
1
2
..

so instead of trying to solve the problem using bash, I wonder how could I print;

0001
0002
...
0009
0010
0011

and so on

Thanks

© Stack Overflow or respective owner

Related posts about c++