Есть много способов сделать это. Простейшим было бы:
int n = 999; char buffer[256]; sprintf(buffer, "%06d", n); string str(buffer);