How can I have multiplication table, in txt output?
Oct 12, 2014 at 4:54pm
Dear Friends,
Would you please help me why the txt output is not in table shape?
But the compiler screen show is in table shape?
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
|
#include <iostream>
#include <fstream>
#include <iomanip>
using namespace std;
int main()
{
const int maxCount = 4;
const int width = 6;
int row;
int column;
ofstream outputFile("output.txt");
for(row=1;row<=10;row++)
{
for(column = 1; column <= maxCount; column++)
{
cout << setw(width) << row * column;
outputFile<<setw(width) << row * column;
}
cout << endl;
}
return 0;
}
|
Oct 12, 2014 at 5:31pm
@spring2014
You're not sending the newline to the saved file, just to screen. Add a outputFile<<endl;
before or after your cout << endl;
Oct 12, 2014 at 5:38pm
Lots of thankssssssssssssssssssssss
Topic archived. No new replies allowed.