#include<iostream>
using namespace std;
int main ()
{
int x;
cout << "Pls. enter a natural number" << "\n" ;
cin >> x ;
cout << "\n" ;
for (int i=1 ; i<=x ; i++ )
{
x = x-1;
cout << i << " " << x << "\n" ;
}
cout << "\n" ;
system ("pause");
return 0;
} $
I have this sample code with cin first then cout.. my problem is that instead of the cout to output in the cmd it will be sent to a .txt file.. Where will I include the fstream codes.. thanks a lot…
Use
<fstream>:If you factor your printing code out, you can use either files or iostreams: