You can convert integers into strings with the help of stringstreams.

The I/O streams also have manipulators of which setfill and setw might be relevant to this task.
Basically, if you can print strings such as that with cout, you practically have the code that is needed to send them to strings instead of console output.