我正在尝试编译这个,但我收到错误error: ‘setioflags’ was not declared in this scope
,这听起来像是试图将其识别为变量。这是我直接从我的教科书中复制的例子,多次检查并且找不到错误。我忽略了什么吗?我在Mac上如果有所作为,我知道<conio.h>
库不起作用,但<iomanip>
被识别
#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;
}