title: convert a string to integer in c++ without losing leading zeros
body: <p>hello i have a problem with converting a string of numbers to integer.
  the problem is that using atoi() to convert the string to integer i loose the leading zeros.
  can you please tell me a way to do that without loosing the leading zeros? </p>
  
  <pre><code>#include &lt;fstream&gt;
  #include &lt;iostream&gt;
  #include &lt;iomanip&gt;
  #include &lt;string&gt;
  
  
  using namespace std;
  
  struct Book{
      int id;
      string title;
  };
  
  struct Author{
      string firstName; 
      string lastName;
  };
  
  Author authorInfo[200];
  Book bookInfo[200];
  
  void load ( void )
  {
  
      int count = 0;
      string temp;
  
      ifstream fin;
      fin.open("myfile.txt");
  
      if (!fin.is_open())
      {
          cout &lt;&lt; "Unable to open myfile.txt file\n";
          exit(1);
      }
  
      while (fin.good())
      {   
          getline(fin, temp, '#');
          bookInfo[count].id = atoi(temp.c_str());
          getline(fin, bookInfo[count].title, '#');
          getline(fin, authorInfo[count].firstName, '#');
          getline(fin, authorInfo[count].lastName, '#');
          count++;
      }
  
      fin.close(); 
  }
  </code></pre>