title: How to force a preceding 0 to an int (without actually outputting it)
body: <p>So I'm trying to force a preceding <code>0</code> to an <code>int</code> so it can be processed later on. Now, all the tutorials i've seen on SO, or any other website, all use something similar to this:</p>
  
  <pre><code>cout &lt;&lt; setfill('0') &lt;&lt; setw(2) &lt;&lt; x ;
  </code></pre>
  
  <p>Whilst this is great, i can only seem to get it to work with <code>cout</code>, however, I don't want to output my text, i just want the number padded, for later use. </p>
  
  <p>So far, this is my code.. </p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;string&gt;
  #include &lt;iomanip&gt; 
  #include &lt;stdio.h&gt;
  #include &lt;stdlib.h&gt;
  #include &lt;string.h&gt; 
  #include &lt;vector&gt;
  #include &lt;sstream&gt;
  
  /*
  using std::string;
  using std::cout;
  using std::setprecision;
  using std::fixed;
  using std::scientific;
  using std::cin;
  using std::vector;
  */
  using namespace std;
  
  void split(const string &amp;str, vector&lt;string&gt; &amp;splits, size_t length = 1)
  {
      size_t pos = 0;
      splits.clear();    // assure vector is empty
  
      while(pos &lt; str.length())    // while not at the end
      {
          splits.push_back(str.substr(pos, length));    // append the substring
          pos += length;                                // and goto next block
      }
  }
  
  int main()
  {
      int int_hour;
      vector&lt;string&gt; vec_hour;
      vector&lt;int&gt; vec_temp;
  
      cout &lt;&lt; "Enter Hour: ";
      cin &gt;&gt; int_hour;
  
      stringstream str_hour;
      str_hour &lt;&lt; int_hour;
  
      cout &lt;&lt; "Hour Digits:" &lt;&lt; endl; 
      split(str_hour.str(), vec_hour, 1);
      for(int i = 0; i &lt; vec_hour.size(); i++)
      {
          int_hour = atoi(vec_hour[i].c_str());
          printf( "%02i", int_hour);
          cout &lt;&lt; "\n";
      }   
  
      return 0;
  }
  </code></pre>
  
  <p>The idea being to input an <code>int</code>, then cast it to a <code>stringstream</code> to be split into single characters, then back to an integer. However, anything less than the number 10 (&lt;10), I need to be padded with a 0 on the left.</p>
  
  <p>Thanks guys </p>
  
  <p>EDIT:
  The code you see above is only a snippet of my main code, this is the bit im trying to make work.</p>
  
  <p>Alot of people are having trouble understanding what i mean. so, here's my idea. Okay, so the entire idea of the project is to take user input (time (hour, minute) day(numeric, month number), etc). Now, i need to break those numbers down into corresponding vectors (vec_minute, vec_hour, etc) and then use the vectors to specify filenames.. so like:
     cout &lt;&lt; vec_hour[0] &lt;&lt; ".png";
     cout &lt;&lt; vec_hour[1] &lt;&lt; ".png";</p>
  
  <p>Now, i know i can use for loops to handle the output of vectors, i just need help breaking down the input into individual characters. Since i ask users to input all numbers as 2 digits, anything under the number 10 (numbers preceding with a 0), wont split into to digits because the program automatically removes its preceding 0 before the number gets passed to the split method (ie. you enter 10, your output will be 10, you enter 0\n9, and your output will be a single digit 9). I cant have this, i need to pad the any number less than 10 with a 0 before it gets passed to the split method, therefore it will return 2 split digits. I cast the integers into stringstreams because thats the best way for splitting data types i found (incase you were wondering).</p>
  
  <p>Hope i explained everything alot better :/</p>