And it does work as long as you are guaranteed to have digits in your input. Except that when I ran the program, I got an error message because there were a couple of cases where I have letters rather than digits in my input file. And the sprinft formatting string fails in this case. These letters are not really an error, but the indication of a special exception condition that still needs to be handled.

so that if my input is "foo", I'll get "00foo" which, even if it does not seem to make too much sense, is what I need in this case to have the logic of my program working in this case (I need to pad my data with 0's at the beginning of my value, in order to be able to compare data from 2 different files with similar values but different formatting conventions.

This was just to say that the "%05s" format string might just be more general than "%05d" in some real life situations. I haven't tested it against my data yet, I'll do that tomorrow morning.