title: How can I increment a number in a string form in C++?
body: <p>Ok so I am learning C++. I want check to see how many files exist for a bank account program for class. My method of doing this is to run a loop to run through and attempt to open "0000000001.txt" to see if it is valid, then "0000000002.txt", and so on. The difficult part is the numbers have the leading zeros( it needs to be a total of 10 digits before ".txt".</p>
  
  <pre><code>double num_of_accounts() {
      double number_of_accounts = 0;
      double count = 0;
      double testFor = 0000000000;
  
      ofstream ifile;
      string filename = "0000000000";
  
      for (count = 0; 0 &lt; /*MAX_NUMBER_OF_ACCOUNTS*/ 5; count++){
          ifile.open(filename + ".txt");
          if (ifile) { number_of_accounts++; }
  
  
             // I would like to increment the number in the filename by 1 here
  
  
      } // END of for (count = 0; 0 &lt; MAX_NUMBER_OF_ACCOUNTS; count++){
  
      return number_of_accounts;
  }
  </code></pre>
  
  <p>Or possibly a way to format the double to be 10 digits long and then convert to string using to_string()? I tried googling it but I don't know if I am using the wrong keywords. </p>
  
  <p>This  is on win console if that helps.</p>
  
  <p>Thank you</p>