title: How to output content in multiple (.txt) files
body: <p>I created a program that can take an integer as its input from a file and generate multiplication tables from 1 up to that integer read from the file. For example, if the program reads (3) from the file, it will output:</p>
  
  <pre><code>1*1 = 1
  1*2 = 2
  ... up to
  1*10 = 10
  and then 
  2*1 = 1 
  .....
  2*10 = 10
  and so on up to three suppose that the number read from the file is 3
  3*1 = 1
  ....
  3*10 = 30
  </code></pre>
  
  <p>Now, I am trying to output each multiplication tables in different (.txt) files where for example table1.txt would contain <code>1*1 = 1 .... up to 1*10 = 10</code> and table2.txt would contain <code>2*1 = 2 .... up to 2*10 = 10</code> and the same procedure for table3.txt.</p>
  
  <p>I can only create one file that only contains the first multiplication table and I do not know how to display the rest of the tables in different files.</p>
  
  <p>I would really appreciate any help or insights to solve this problem. Thank you!</p>
  
  <p>This is what I have:</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;fstream&gt;
  
  using namespace std;
  
  int main ()
  {
      int num, a, b;
      fstream inputStream;
      ofstream outputStream;
  
      inputStream.open("input.txt"); //let's say input.txt holds the number 3
  
      while (inputStream &gt;&gt; num)
      outputStream.open("table.txt");
  
      for (a = 1; a &lt;= num; a++) 
      {
          for (b = 1; b &lt;= 10; b++)
          {
              outputStream &lt;&lt; a &lt;&lt; " X "
                     &lt;&lt; b &lt;&lt; " = "
                     &lt;&lt; a*b &lt;&lt; endl;
          }
          inputStream.close();
          outputStream.close();
      }                  
      return 0;
  }
  </code></pre>