我想用setw來清理我的程序的輸出。我想要「訂購的假脫機總數」和輸出之間的空白空間。C++ setw移動整行不只是需要的部分
編輯這是我去爲:
,這就是我得到 這裏是我到目前爲止有: 更新的代碼
/********************************************/
// Name: results /
// Description: Print results /
// Parameters: N/A /
// Reture Value: N/A /
/********************************************/
void results(int spoolnumber, int subtotalspool, float shippingcost, float totalcost)
{
cout << left << setw (45) << "Total number of spools to be ordered is: " << right << spoolnumber << endl << endl;
cout << left << setw (45) << "The subtotal for the spools is:" << right << "$" << subtotalspool << endl << endl;
cout << "The shipping cost is: $" << shippingcost << endl << endl;
cout << "The total cost is: $" << totalcost << endl << endl;
return;
}
羅布的規則#8:當你的意思是''\ n''時不要說'endl'。參見[endl fiasco](http://stackoverflow.com/questions/5492380/what-is-the-c-iostream-endl-fiasco/5492605#5492605)。 –
+1根據反饋澄清問題 –
@ Steve Townsend:問題越好,答案越好。 –