I have kind of a silly question...
I am trying to display an Integer as 0001, istead of 1. And when I increment it, I need it to be 0002, 0003, ....0124, etc. Does anyone know how I can do so?
Thanks,
Jeff
Printable View
I have kind of a silly question...
I am trying to display an Integer as 0001, istead of 1. And when I increment it, I need it to be 0002, 0003, ....0124, etc. Does anyone know how I can do so?
Thanks,
Jeff
Using C++:
Using C:Code:#include <iostream>
#include <iomanip>
int main()
{
int i = 1;
std::cout << std::setw(4) << std::setfill('0') << i; // prints "0001"
return 0;
}
Code:#include <stdio.h>
int main()
{
int i = 1;
printf("%04i",i); // 0001
return 0;
}