InputOutput - C+I/O MengSu 10/21/11 1...

Info iconThis preview shows pages 1–6. Sign up to view the full content.

View Full Document Right Arrow Icon
10/21/11 1 C++ I/O Meng Su
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
 The C++ Standard I/O Classes n A stream is just a sequence of characters, nothing else . n C++ has  <iostream>  library The following two classes are defined in library n ostream   for output ( screen, disk file) n istream   for input ( keyboard, disk file)
Background image of page 2
The  istream   Class n Input operator >> istream inst; inst >> variable; n Another input stream operation inst.getline(char chAry[], int n) ,…… For more Input Stream Operations see text page 199 Table 5-2 , and  Appendix D   n A well-known input stream defined in <iostream> cin : standard input stream (keyboard)   cin >> variable;
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
How input >> works ? n Rule: with simple types:  leading white space (space, tab, newline,  carriage-return) is skipped!!!   int ID; char Name[40]; char ch; cin >> ID; // interprets as integer cin >> ch; // reads a char cin >> Name; //interprets as character string, // stopping at trailing white space!
Background image of page 4
Input error state n Stream input “fails” if the next thing in the input has the 
Background image of page 5

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 6
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 15

InputOutput - C+I/O MengSu 10/21/11 1...

This preview shows document pages 1 - 6. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online