title: Output to Time to File Multiple Times in C++ by Running Program Multiple Times
body: <p>I want to output the time it takes my C++ program to run to a file on my desktop called C10.txt. I want to run the program 100 times and then when I open the file, it tells me all of the different times that the program took to run. I know I need fstream to do this, but I have no clue where to go from there. Here is the code I want to run multiple times. What should I add to it to make this work?</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;cmath&gt;
  #include &lt;fstream&gt;
  
  using namespace std;
  
  void merge(int*,int,int);
  void mergeSort(int*,int,int);
  
  
  const int ARRAYSIZE = 10;
  
  int main()
  {
  
      clock_t startTime = clock();
      srand(unsigned(time(0)));
  
      cout &lt;&lt; (double( clock() - startTime ) / (double)CLOCKS_PER_SEC) * 1000000&lt;&lt;  " microseconds." &lt;&lt; endl;
  
  
      return 0;
  }
  </code></pre>