Input/Output (lecture 5)

Get Started. It's Free
or sign up with your email address
Input/Output (lecture 5) by Mind Map: Input/Output (lecture 5)

1. read data from the standard input device

2. Predefined Functions

2.1. #include <cmath>

2.1.1. pow(x,y)

2.1.1.1. x and y are the arguments or parameters(参数)

2.1.2. squrt

2.1.2.1. Value whose square root is computed.

2.2. organized as a collection of libraries called header files

3. what is a stream?

3.1. input stream(cin)

3.1.1. sequence of characters from an input device to computer

3.1.2. Whitespace characters : blanks and certain nonprintable characters

3.1.3. If it is of type char, the 2 is treated as character 2 If it is of the type int (or double) the 2 is treated as the number 2

3.1.4. No difference between a single cin with multiple variables and multiple cin statements with one variable

3.1.5. Two variables can be read using a single cin statement

3.1.6. the extraction operator >>

3.1.7. Input stream variables: type istream

3.1.8. when reading char: skip leading whitespace, stops after a single character.

3.1.9. when reading int or double: skip leading whitespace, read plus or minus, read digits; Reading stops on whitespace non-digit character.

3.1.10. get Function: Inputs next character (including whitespace)

3.1.10.1. cin.get(varChar);

3.1.10.1.1. varChar

3.1.10.1.2. cin and get are two separate identifiers separated by a dot.

3.1.11. ignore Function

3.1.11.1. discards a portion of the input

3.1.11.2. cin.ignore(intExp,chExp)

3.1.11.2.1. intExp

3.1.11.2.2. chExp

3.1.11.2.3. ex: cin.ignore(200,/n)

3.1.12. Putback Function

3.1.12.1. Places previous character extracted by the get function from an input stream back to that stream

3.1.12.1.1. syntax

3.1.13. Peek Function

3.1.13.1. Returns next character from the input stream

3.1.13.1.1. syntax

3.1.13.2. Does not remove the character from that stream

3.1.14. Input Failure

3.1.14.1. in fail state

3.1.14.1.1. further I/O statements are ignored

3.2. sequence of bytes, bytes are usually characters.

3.3. output stream(cout)

3.3.1. sequence of characters form computer to an output device

3.3.2. setw

3.3.3. setprecision(n)

3.3.4. fixed

3.3.5. Output stream variables: type ostream

3.4. use iostream to extract(receive) data from keyboard and send output to screen

3.5. preprocessor directive must be used: #include <iostream>