CS 1337 Lecture Notes - Lecture 8: Delimiter, Include Directive

22 views5 pages

Document Summary

//types of stream or files ifstream inputfile; ofstream outputfile; //files - a set of data stored on a computer in a persistent location. //program can read and write data to these files. // description : hello world in c++, ansi-style. //must pass file by ref otherwise won"t work int main() { //in = input file and out = output file. //can make the file both in and out. //put the "|" to open file as input and output fstream file; //more general concept of a file. //gives our program a lot more control and responsibility outputfile. open("test. txt"); outputfile << 3. 14 << endl; outputfile << 3 << endl; outputfile << "jonathan" << endl; //can use the extraction and insertion operators >> , << //eof function tells us when we"ve reached the end of the file outputfile. close(); fstream afile; //ios::app - append by default, all writing occurs at the end of the file. //ios::in - file for input it must already exist.

Get access

Grade+
$40 USD/m
Billed monthly
Grade+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
10 Verified Answers
Class+
$30 USD/m
Billed monthly
Class+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
7 Verified Answers

Related Documents