dimanche 26 mai 2019

Output formatting using setw and setfill

I'm trying to get the following output using setw and setfill:

OPTIONS:
    <expression>
       The usual operators +, -, *, / and % (remainder)
       Expressions are fixed-point decimal numbers, and
       Parentheses () and corchetes {} may be used for grouping.

I'm trying like this:

    cout << "OPTIONS:" << '\n';
    cout << "\t<expression>\n";
    cout << '\t' << setw(3) << setfill(' ') << "The usual operators +, -, *, / and % (remainder)\n";
    cout << '\t' << setw(3) << setfill(' ') << "Expressions are fixed-point decimal numbers, and\n";
    cout << '\t' << setw(3) << setfill(' ') << "Parentheses () and corchetes {} may be used for grouping.\n\n";

Aucun commentaire:

Enregistrer un commentaire