Computer Science - Object Oriented Programming Using C++ - Discussion

Discussion Forum : Object Oriented Programming Using C++ - Section 1 (Q.No. 4)
4.
Format flags may be combined using
the bitwise OR operator (|)
the logical OR operator (||)
the bitwise AND operator (&)
the logical AND operator (&&)
Answer: Option
Explanation:
No answer description is available. Let's discuss.
Discussion:
21 comments Page 1 of 3.

Supriya said:   3 years ago
3what is mean by format flag? Explain, please.
(1)

Taruni said:   7 years ago
What is meant by format flag?

Aakash kr said:   7 years ago
Realy, I want to know what is format flag?

Shashank Singh said:   8 years ago
cout and cin contain several single-bit flags for format control. They are named in an enum in class ios as:

ios::skipws // skips whitspace on input
ios::left // left justification
ios::right // right justifiction
ios::internal // pads after sign or base character
ios::dec // decimal format for integers
ios::oct // octal format for integers
ios::hex // hex format for integers
ios::showbase // show the base character for octal or hex
ios::showpoint // show the decimal point for all floats
ios::uppercase // uppercase A-F for hex
ios::showpos // show +ve sign for numbers
ios::scientific // use exponential notation
ios::fixed // used oridnary decimal notation
ios::unitbuf // flush the buffer

These flags can be set with the member function setf. e.g.

cout.setf(ios::showpos);

They can be or'd together:
cout.setf(ios::showpos | ios::uppercase);
or some bits can be unset while one is being set:
cout.setf(ios::oct, ios::dec | ios::oct | ios::hex);

This sets the bit for oct, after unsetting the bits for oct, dec and hex, ensuring that only one of the bits is turned on.
unsetf turns bits off:
cout.unsetf(ios::showpos);
(1)

Jayasree said:   8 years ago
Please, be clear what are format flags?
(1)

Tushar said:   8 years ago
Can anyone tell me what is format flags, and what is its use?

Johny said:   8 years ago
It is actually very beneficial. Thanks @Sunder.

Somya Agrawal said:   9 years ago
What are format flags? Please describe it in detail.

Preet said:   9 years ago
It is denoted by the virtual number.

Gursimran said:   9 years ago
Thanks @Sundar. It helps me. :)


Post your comments here:

Your comments will be displayed after verification.