don't use magic numbers. use file_name.width( 3 ); and file_name<< std::setfill( '0' );