Input/Output

28 flashcardsby John
Study these flashcardsFree · spaced repetition · iPhone, Android, Mac & web

All cards

1
What to include for cin and cout
<iostream>
2
What does cin.clear() do?
Sets a new value for the stream's internal error state flags.
The current value of the flags is overwritten: All bits are replaced by those in state; If state is goodbit (which is zero) all error flags are cleared.
3
What does cin.ignore() do?
Extracts characters from the input sequence and discards them, until either n characters have been extracted, or one compares equal to delim.
4
What does wrapping cin in an if statement do?
In C++, stream classes implement operator bool() which allows them to be implicitly converted to a boolean. This boolean indicates whether the streams are in a good or bad state.
5
%d
decimal
6
%x or %X
Hex and Hex uppercase
7
%f
float
8
%e
scientific notation
9
%E
Scientific notation uppercase
10
%c
character
11
%s
string of characters
12
%p
pointer adress
13
%n
stores the number of characters at a pointer in a signed int
14
flag -
left justify
15
flag +
shows sign of numbers
16
flag #
Shows 0x or 0X before hex values and forces decimal point on numbers
17
flag 0
Left pads with zeros instead of spaces
18
printf usage
%[flags][width][.precision]specifier
19
width *
width is stored in variable section
20
I/O manipulators included in <iostream>
endl, fixed, showpoint
21
I/O Manipulators in <iomanip>
setw(), setprecision(), scientific, hex, dec, setfill(' '), left, right
22
The only io manipulaitor that is not persistent
setw()
23
How to check if cin failed
if (!cin)
24
How to put cin back to normal after error
cin.clear() - clears error messages
25
How to remove bad input from cin and what do you include
cin.ignore(numeric_limits<streamsize>::max(), '\n'), #include <limits>
26
Condition for s while loop that exits on good input
!cin.good()
27
how to use scanf?
scanf("%[flags][width][.precision]specifier", specifier_data_type)
28
what to include for scanf and printf?
#include <cstdio.h>
Study all 28 cards for free