title: How do I limit the file size so my program creates a new file after it becomes too large? and edit the name of the newly created file?
body: <p>As I run my code it builds the text file which quickly exceeds a size where I can effectively use it.</p>
  
  <p>How would I set a size limit to the text size so that it creates a new text file with a title +1 of the previous file?</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;vector&gt;
  #include &lt;string.h&gt;
  #include &lt;iostream&gt;
  #include &lt;vector&gt;
  #include &lt;fstream&gt;
  
  using namespace std;
  
  void Crack(string password, vector&lt;char&gt; Chars)
  {
  
      ofstream myfile;
      myfile.open ("pass.txt");
  
  
      myfile&lt;&lt;"PASSWORDs TO CRACK: 0 to "&lt;&lt;password&lt;&lt;endl;
      int n = Chars.size();
      int i = 0;
      while(true)
          {
              i++;
              int N = 1;
              for(int j=0;j&lt;i;j++)N*=n;
              for(int j=0;j&lt;N;j++)
                  {
                      int K = 1;
                      string crack = "";
                      for(int k=0;k&lt;i;k++)
                          {
                              crack += Chars[j/K%n];
                              K *= n;
                          }
                      myfile&lt;&lt; crack&lt;&lt;" "&lt;&lt;endl;
                      if(password.compare(crack) == 0){
                      myfile&lt;&lt;"Cracked password: "&lt;&lt;crack&lt;&lt;endl;
                      return;
                      myfile.close();
                      }
                  }
          }
  }
  int main()
  {
      vector&lt;char&gt; Chars;
      for(char c = '0';c&lt;='z';c++){
      if(islower(c) || isdigit(c))Chars.push_back(c);
      }
      Crack("zzzzzzzzzzzzzzzzzz", Chars);
  }
  </code></pre>