streams and file i/o in c++ - ontario tech u · streams and file i/o in c++ summary ! discussed...
TRANSCRIPT
![Page 1: Streams and File I/O in C++ - Ontario Tech U · Streams and File I/O in C++ Summary ! Discussed file input and output in C++ using streams ! Writing to files, reading from files,](https://reader030.vdocuments.mx/reader030/viewer/2022041015/5ec749c82f84eb1895630650/html5/thumbnails/1.jpg)
Streams and File I/O in C++
Last Lecture § Overview of the four kinds of namespaces in C++
§ Standard namespace, user-defined namespaces, unnamed namespace, global namespace
§ Reviewed using g++ to compile C++ programs in Linux
© J.S. Bradbury CSCI 1060U Lecture 5 Slide 1
![Page 2: Streams and File I/O in C++ - Ontario Tech U · Streams and File I/O in C++ Summary ! Discussed file input and output in C++ using streams ! Writing to files, reading from files,](https://reader030.vdocuments.mx/reader030/viewer/2022041015/5ec749c82f84eb1895630650/html5/thumbnails/2.jpg)
Streams and File I/O in C++
Overview
§ File input and output in C++ using streams § Writing to files § Reading from files § Appending to files
§ Overloading the << and >> operators for streams
© J.S. Bradbury CSCI 1060U Lecture 5 Slide 2
![Page 3: Streams and File I/O in C++ - Ontario Tech U · Streams and File I/O in C++ Summary ! Discussed file input and output in C++ using streams ! Writing to files, reading from files,](https://reader030.vdocuments.mx/reader030/viewer/2022041015/5ec749c82f84eb1895630650/html5/thumbnails/3.jpg)
File I/O: Writing and Reading
CSCI 1060U Lecture 5 Slide 3 © J.S. Bradbury
See fileio_ex1.cpp for example of how to open a file, write to a file, read from a file and close a file.
See fileio_ex2.cpp for handling file i/o errors gracefully. For example, errors with files not existing or file permission problems.
![Page 4: Streams and File I/O in C++ - Ontario Tech U · Streams and File I/O in C++ Summary ! Discussed file input and output in C++ using streams ! Writing to files, reading from files,](https://reader030.vdocuments.mx/reader030/viewer/2022041015/5ec749c82f84eb1895630650/html5/thumbnails/4.jpg)
File I/O: Appending
CSCI 1060U Lecture 5 Slide 4 © J.S. Bradbury
See fileio_ex3.cpp for reading from a file (line-by-line) and appending to a file.
![Page 5: Streams and File I/O in C++ - Ontario Tech U · Streams and File I/O in C++ Summary ! Discussed file input and output in C++ using streams ! Writing to files, reading from files,](https://reader030.vdocuments.mx/reader030/viewer/2022041015/5ec749c82f84eb1895630650/html5/thumbnails/5.jpg)
Streams and File I/O in C++
Summary § Discussed file input and output in C++ using
streams § Writing to files, reading from files, appending to files
§ Learned how to overload the << and >> operators for streams
Next Time § More file input/output using streams and then
exception handling.
© J.S. Bradbury CSCI 1060U Lecture 5 Slide 5
![Page 6: Streams and File I/O in C++ - Ontario Tech U · Streams and File I/O in C++ Summary ! Discussed file input and output in C++ using streams ! Writing to files, reading from files,](https://reader030.vdocuments.mx/reader030/viewer/2022041015/5ec749c82f84eb1895630650/html5/thumbnails/6.jpg)
Streams and File I/O in C++
Readings § …
References § …
© J.S. Bradbury CSCI 1060U Lecture 5 Slide 6