Hi everyone:
I have what is probably a dumb question about using cout to display a 2-D array on screen.
I want my code (below) to output an array to the screen once. But instead, it is outputting it row-by row. The entire array is shown after many unfinished arrays are shown.
I would appreciate it a lot if someone could tell me how to suppress all the intermediate/unfinished arrays so that only the finished array appears. Thanks a lot.
for (int i = 0; i < rows; i++)
{
for (int j = 0; j < cols; j++)
{
cout << setiosflags(ios::showpoint | ios::fixed | ios::right)
<< setprecision(4)
<< setw(12)
<< m[j];
}
cout << endl;
}
Hi Cubbi--thanks for your help. Sorry I was unclear. What I mean is that I would like ONLY my finished matrix to appear on the screen.
Right now what is happening is that the matrix appears repeatedly--with a new row filled in each time it appears.
So instead of something like:
[1][2][3]
[4][5][6]
[7][8][9]
I get:
[1][2][3]
[0][0][0]
[0][0][0]
then:
[1][2][3]
[4][5][6]
[0][0][0]
then:
[1][2][3]
[4][5][6]
[7][8][9]
Is there a way to suppress the intermediate steps? I have a LOT of output and it would be great to only have to deal with the finished product. Thanks!
I have what is probably a dumb question about using cout to display a 2-D array on screen.
I want my code (below) to output an array to the screen once. But instead, it is outputting it row-by row. The entire array is shown after many unfinished arrays are shown.
I would appreciate it a lot if someone could tell me how to suppress all the intermediate/unfinished arrays so that only the finished array appears. Thanks a lot.
for (int i = 0; i < rows; i++)
{
for (int j = 0; j < cols; j++)
{
cout << setiosflags(ios::showpoint | ios::fixed | ios::right)
<< setprecision(4)
<< setw(12)
<< m[j];
}
cout << endl;
}
Hi Cubbi--thanks for your help. Sorry I was unclear. What I mean is that I would like ONLY my finished matrix to appear on the screen.
Right now what is happening is that the matrix appears repeatedly--with a new row filled in each time it appears.
So instead of something like:
[1][2][3]
[4][5][6]
[7][8][9]
I get:
[1][2][3]
[0][0][0]
[0][0][0]
then:
[1][2][3]
[4][5][6]
[0][0][0]
then:
[1][2][3]
[4][5][6]
[7][8][9]
Is there a way to suppress the intermediate steps? I have a LOT of output and it would be great to only have to deal with the finished product. Thanks!