CSC138 Chapter 4 - File IO.ppt - CSC138 STRUCTURED PROGRAMMING Chapter 4 Fundamental of Data Files Compiled by Rashidah Mokhtar BK79 0197333604

CSC138 Chapter 4 - File IO.ppt - CSC138 STRUCTURED...

This preview shows page 1 - 9 out of 27 pages.

CSC138: STRUCTURED PROGRAMMING Chapter 4: Fundamental of Data Files Compiled by: Rashidah Mokhtar BK79 0197333604 https:// -
Image of page 1

Subscribe to view the full document.

Introduce the six step process i. include header file fstream ii. declare file object ofstream/ifstream iii. open file iv. check if file is opened successfully v. perform operation vi. close file W11 Lab4.1: Compare input/output process from text files and console
Image of page 2
Objectives 3
Image of page 3

Subscribe to view the full document.

Introduction 4 Data stored in variables, arrays and objects are temporary. To store permanently, we need to save in a storage. File - an area in secondary storage used to hold information Concept of file input output (I/O) Concept of file input output (I/O)
Image of page 4
Introduction (cont..) 5 The most important functions which will be used for any file operations are: fstream::open function - to open the file. fstream::Operator >> (right-shift operator) - for reading from file. fstream::Operator << (left-shift operator) - for writing to the file. fstream::close - Flushes all buffer and close the file Header files Header files
Image of page 5

Subscribe to view the full document.

3 things you need to have! 6 A file A file stream object A mode
Image of page 6
1. File 7 Create an input file to store your data using text editor such as notepad. Example: Save the file as .txt or .dat: Eg: summon.txt or summon.dat .
Image of page 7

Subscribe to view the full document.

2. File stream 8 A file stream is a one way transmission path to connect a file stored on physical device to a program.
Image of page 8
Image of page 9
  • Fall '18

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern

Ask Expert Tutors You can ask You can ask ( soon) You can ask (will expire )
Answers in as fast as 15 minutes