You can write to a file instead of your screen.
Code:
#include<iostream>
#include <fstream> //for ofstream
using namespace std;
int main()
{
ofstream myOutputFile("C:\\TestData\\output.txt");
for(int i=0; i<10; i++)
{
myOutputFile<<i<<"\n";
}
return 0;
}
or, do both:
Code:
#include<iostream>
#include <fstream> //for ofstream
using namespace std;
int main()
{
ofstream myOutputFile("C:\\TestData\\output.txt");
for(int i=0; i<10; i++)
{
myOutputFile<<i<<"\n"; //output to file
cout<<i<<"\n"; //output to screen
}
return 0;
}