Print "01" in Place of "1"

I just read how to do this two days ago, but can't remember where I saw it. What I am trying to do is take in integer value int x = 1; and have it print out to the console as 01.
1
2
3
if (i>0 && i<10)
    cout << 0;
  cout << i;


Also:
dwhitney67 at ubuntuforums wrote:
1
2
3
4
5
6
7
8
9
#include <iostream>
#include <iomanip>

int main()
{
   int i = 1;

   std::cout << std::setw(2) << std::setfill('0') << i << std::endl;
}
Topic archived. No new replies allowed.