int n = 6, m = 2;
char format[10];
char hoge[10];

sprintf( format, "%%0%dd", n );
sprintf( hoge, format, m );