Presentation is loading. Please wait.

Presentation is loading. Please wait.

Computer Science: A Structured Programming Approach Using C1 Objectives ❏ To understand the differences between text and binary files ❏ To write programs.

Similar presentations


Presentation on theme: "Computer Science: A Structured Programming Approach Using C1 Objectives ❏ To understand the differences between text and binary files ❏ To write programs."— Presentation transcript:

1 Computer Science: A Structured Programming Approach Using C1 Objectives ❏ To understand the differences between text and binary files ❏ To write programs that read, write, and/or append binary files ❏ To be able to detect and take appropriate action when file errors occur ❏ To be able to process files randomly ❏ To be able to create text files from binary files and vice versa ❏ To understand and be able to implement file merges ❏ To understand and be able to implement the classic sequential file update Chapter 13 Chapter 13 Binary Input/Output Binary Input/Output

2 Computer Science: A Structured Programming Approach Using C2 13-1 Text versus Binary Streams In this section, we compare and contrast text streams versus binary streams. Text and Binary Files Differences between Text and Binary Files State of a File Opening Binary Files Closing Binary Files Topics discussed in this section:

3 Computer Science: A Structured Programming Approach Using C3 FIGURE 13-1 Reading and Writing Text Files

4 Computer Science: A Structured Programming Approach Using C4 Formatted input/output, character input/output, and string input/output functions can be used only with text files. Note

5 Computer Science: A Structured Programming Approach Using C5 FIGURE 13-2 Block Input and Output

6 Computer Science: A Structured Programming Approach Using C6 FIGURE 13-3 Binary and Text Files

7 Computer Science: A Structured Programming Approach Using C7 Text files store data as a sequence of characters; binary files store data as they are stored in primary memory. Note

8 Computer Science: A Structured Programming Approach Using C8 Table 13-1File Modes

9 Computer Science: A Structured Programming Approach Using C9 FIGURE 13-4 File States

10 Computer Science: A Structured Programming Approach Using C10 FIGURE 13-5 File-Opening Modes

11 Computer Science: A Structured Programming Approach Using C11 13-2 Standard Library Functions for Files C has eight categories of standard file library functions. We have already discussed the first four in Chapter 7 and Chapter 11. We discuss the other four categories, which are more related to binary files, in this section. Block Input/Output Functions File Status FunctionsComments Positioning Functions System File Operations Topics discussed in this section:

12 Computer Science: A Structured Programming Approach Using C12 FIGURE 13-6 Types of Standard Input/Output Functions

13 Computer Science: A Structured Programming Approach Using C13 FIGURE 13-7 File Read Operation

14 Computer Science: A Structured Programming Approach Using C14 PROGRAM 13-1Read File of Integers

15 Computer Science: A Structured Programming Approach Using C15 FIGURE 13-8 Reading a Structure

16 Computer Science: A Structured Programming Approach Using C16 PROGRAM 13-2Read Student File

17 Computer Science: A Structured Programming Approach Using C17 FIGURE 13-9 File Write Operation

18 Computer Science: A Structured Programming Approach Using C18 FIGURE 13-10 Writing a Structure

19 Computer Science: A Structured Programming Approach Using C19 PROGRAM 13-3Write Structured Data

20 Computer Science: A Structured Programming Approach Using C20 FIGURE 13-11 Rewind File

21 Computer Science: A Structured Programming Approach Using C21 FIGURE 13-12 Current Location (ftell) Operation

22 Computer Science: A Structured Programming Approach Using C22 FIGURE 13-13 File Seek Operation

23 Computer Science: A Structured Programming Approach Using C23 PROGRAM 13-4Append Two Binary Files

24 Computer Science: A Structured Programming Approach Using C24 PROGRAM 13-4Append Two Binary Files

25 Computer Science: A Structured Programming Approach Using C25 PROGRAM 13-4Append Two Binary Files


Download ppt "Computer Science: A Structured Programming Approach Using C1 Objectives ❏ To understand the differences between text and binary files ❏ To write programs."

Similar presentations


Ads by Google