input output stream Flashcards
1
Q
What is the header of cin and cout
A
// #include
2
Q
How to display string of binary 10 digit value 7 in decimal
A
std: :bitset<10> value(7);
std: :cout «_space;value;
3
Q
What std function to read one line of string from input stream?
A
std::getline
Ex:
std::string input;
std::getline(cin, input);
4
Q
What is the simple way to read input data until end of file?
A
string input_data;
while ( !cin.eof() ) {
getline( cin, input_data);
}
5
Q
How to tell cout to display true or false instead of 0 or 1?
A
cout «_space;boolalpha;
6
Q
Show how to use stringstream for input stream.
A
#include ... stringstream sin( "123456\n" "xxxyes\n" ) string line; getline(sin, line);
7
Q
How to display double in two decimal precision
A
cout «_space;std::fixed «_space;setprecision(2); «_space;value;