nv3's answer is the way to go if you're using C.
std::cout << std::setw( 2 ) << std::setfill( '0' ) << 5 << std::endl;
std::cout << std::setw( 2 ) << std::setfill( '0' ) << 25 << std::endl;
is the C++ way. If you're using C++ then don't use printf, it's not the safest way of doing output in the world.