Class Notes (1,100,000)
CA (630,000)
UW (20,000)
CS (1,000)
CS138 (10)
Lecture 4

CS138 Lecture Notes - Lecture 4: Entry Point, Ergi


Department
Computer Science
Course Code
CS138
Professor
Michael Godfrey
Lecture
4

This preview shows page 1. to view the full 4 pages of the document.
Data Lecture 4
January 17, 2013
Manipulate I/O
Look at <iomanip>
Justification
Padding
Some random syntax
o cin get input
o cout print output
o cerr print error messages
o << write output
o >> get input
Input and whitespace
o cin>>foo>bar;
42----------43
string line;
getline(cin, line);
Input and EOF
o eof()
True if EOF
o fail()
True if EOF
o Equivalent statements:
if(istr)
if(!istr.fail())
int main (--) {
double sum=0;
int count=0;
while (true) {
double next;
while (cin>>next) {
sum +=next;
count++;
}
}
...
}
You're Reading a Preview

Unlock to view full version