G
Guest
The code:
// Block 1
//
cout << "Integrating " << str << " on [" << low << "," << high
<< "]" << endl << " exact answer: " << exact << endl << flush;
#if 0
// Block 2
//
for (int i = 0; i < 6; ++i )
{
cout << setw(16) << setiosflags(ios::left) << label << flush;
cout << setiosflags(ios::right) << setw(20) << setiosflags(ios::fixed)
<< setprecision(17) << answer;
cout << " error: " << fabs(exact - answer) << endl;
}
#endif
The output looks like:
Integrating x on [0,10]
exact answer: 50
However, when I delete the "#if 0" and "#endif", the output becomes:
Integrating x on [0.00000000000000000,10.00000000000000000]
exact answer: 50.00000000000000000
I tried sticking in a "flush" in Block 1 to make sure the buffer is flushed
and unaffected by the manipulators within Block 2. But it doesn't seem to do
a bit of good.
Why is it that the manipulators in block 2 affect the output generated in
block 1?
Thanks,
Pete
// Block 1
//
cout << "Integrating " << str << " on [" << low << "," << high
<< "]" << endl << " exact answer: " << exact << endl << flush;
#if 0
// Block 2
//
for (int i = 0; i < 6; ++i )
{
cout << setw(16) << setiosflags(ios::left) << label << flush;
cout << setiosflags(ios::right) << setw(20) << setiosflags(ios::fixed)
<< setprecision(17) << answer;
cout << " error: " << fabs(exact - answer) << endl;
}
#endif
The output looks like:
Integrating x on [0,10]
exact answer: 50
However, when I delete the "#if 0" and "#endif", the output becomes:
Integrating x on [0.00000000000000000,10.00000000000000000]
exact answer: 50.00000000000000000
I tried sticking in a "flush" in Block 1 to make sure the buffer is flushed
and unaffected by the manipulators within Block 2. But it doesn't seem to do
a bit of good.
Why is it that the manipulators in block 2 affect the output generated in
block 1?
Thanks,
Pete