-4

Here is the snippet of code that prints the output

 void PrintFunc(double Y[])
 {
    for(int i=0 ; i<=N+1 ; i++)
      {
        cout << x_min+i*r << "\t" << Y[i] << endl;
      }
 }

I want to write it to a text file, how do I do it? i ranges from 1 to 2000.

DSha
  • 1
  • 1
  • 2

1 Answers1

1
#include <fstream>
std::ofstream ofs("filename.txt")
// then, in the loop:
    ofs << ... << std::endl;
lorro
  • 10,687
  • 23
  • 36