私のラボでは、出力値を値の文に続く列に表示する必要があります。列内の各値の左端の文字の整列
私が必要とするものの例。私はどちらかsetwはこのために使用するために間違ったことがあるか、それは通常
のようなものをもたらすので、私はそれが間違って使っている私は仮定していsetwようcout << "Amount of adult tickets: " << setw(15) << ticketsAdult` << endl;
cout << "Amount of children tickets: " << setw(15) < ticketsChildren << endl;
を使用しようとしています
Amount of adult tickets: 16
Amount of children tickets: 12
Revenue from ticket sales: $140.22
Amount of adult tickets: 16
Amount of children tickets: 12
私は、彼らがそれらのそれぞれの前に関係なく、一例では文「の...量」の長さもしなかったようにすべてが揃え右に値を作るために何を使用することができますか?
言っhttps://stackoverflow.com/questions/14765155/how-can-i-easily-format-my-data-table-in-c –
'std :: setw'を値ではなく文字列に使用します。タイプミスとして閉じる。 – LogicStuff
正当化修飾子[std :: left、std :: right](http://en.cppreference.com/w/cpp/io/manip/left)を参照してください。 –