char str[7]; snprintf (str, 7, "%06d", n); См. snprintf
char str[7]; snprintf (str, 7, "%06d", n);
См. snprintf