0
我想編譯這個,但我得到錯誤error: ‘setioflags’ was not declared in this scope
這聽起來像它試圖把它識別爲一個變量。這是我從我的教科書中直接複製的一個例子,檢查了好幾遍,並找不到錯誤。我可以忽略一些東西嗎我在Mac上,如果有差別,我知道<conio.h>
庫不會因爲這個工作,但<iomanip>
是公認Setiosflags不被識別
#include <iostream>
#include <iomanip>
using namespace std;
const int DISTRICTS = 4;
const int MONTHS = 3;
int main() {
int d, m;
double sales[DISTRICTS][MONTHS];
cout << endl;
for(d = 0; d < DISTRICTS; d++)
for(m = 0; m < MONTHS; m++)
{
cout << "Enter sales for district " << d+1;
cout << ", month " << m+1 << ": ";
cin >> sales[d][m];
}
cout << "\n\n";
cout << " Month\n";
cout << " 1 2 3";
for(d = 0; d < DISTRICTS; d++)
{
cout << "\nDistrict " << d+1;
for(m = 0; m < MONTHS; m++) // Display array values
cout << setiosflags(ios::fixed) // Not exponential
<< setioflags(ios::showpoint) // Always use poin
<< setprecision(2) // Digits to right
<< setw(10) // Field width
<< sales[d][m]; // Get number from array
} // end for(d)
cout << endl;
return 0;
}
謝謝,有時我只需要第二組眼睛 – Chris 2012-03-04 16:24:21