ENGR 101 Lecture 10: Streams and IO

70 views2 pages
7 Aug 2018
School
Department
Course

Document Summary

A while loop can be used to repeatedly ask the user for input until it satisfies some criteria. A loop can be used to collect input until the user enters a special value, called a sentinel. Cin is an istream object (as well as ifstream) Cout is an ostream object (as well as ofstream) It is easier to work with files that are in the same directory where you run the program. To write output to a file, you use an ofstream object. If the file doesn"t exist, it will be created; If the file already exists, it will be overwritten. Remember to close the file once you are done using it: Will read an input rom a file names "words. in" Sometimes the program is unable to open a file for input because it doesn"t exist or a different program may be using it. Check whether the file opened successfully using fin. is_open()

Get access

Grade+20% off
$8 USD/m$10 USD/m
Billed $96 USD annually
Grade+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
40 Verified Answers
Class+
$8 USD/m
Billed $96 USD annually
Class+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
30 Verified Answers

Related Documents