Top Banner
Computer Science: A Structured Programming Approach Using C 1 3-3 Converting File Type A rather common but somewhat trivial problem A rather common but somewhat trivial problem is to convert a text file to a binary file and vice is to convert a text file to a binary file and vice versa. C has no standard functions for these versa. C has no standard functions for these tasks. We must write a program to make the tasks. We must write a program to make the conversion. We describe the file conversion conversion. We describe the file conversion logic in this section. logic in this section. Creating a Binary File from a Text File Creating a Text File from a Binary File Topics discussed in this section: Topics discussed in this section:
37

13-3 Converting File Type

Jan 01, 2016

Download

Documents

Arthur England

13-3 Converting File Type. A rather common but somewhat trivial problem is to convert a text file to a binary file and vice versa. C has no standard functions for these tasks. We must write a program to make the conversion. We describe the file conversion logic in this section. - PowerPoint PPT Presentation
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: 13-3   Converting File Type

Computer Science: A Structured Programming Approach Using C 1

13-3 Converting File Type

A rather common but somewhat trivial problem is to A rather common but somewhat trivial problem is to convert a text file to a binary file and vice versa. C has convert a text file to a binary file and vice versa. C has no standard functions for these tasks. We must write a no standard functions for these tasks. We must write a program to make the conversion. We describe the file program to make the conversion. We describe the file conversion logic in this section.conversion logic in this section.

Creating a Binary File from a Text FileCreating a Text File from a Binary File

Topics discussed in this section:Topics discussed in this section:

Page 2: 13-3   Converting File Type

Computer Science: A Structured Programming Approach Using C 2

FIGURE 13-14 Create Binary File Structure Chart

Page 3: 13-3   Converting File Type

Computer Science: A Structured Programming Approach Using C 3

PROGRAM 13-5 Text to Binary Student File

Page 4: 13-3   Converting File Type

Computer Science: A Structured Programming Approach Using C 4

PROGRAM 13-5 Text to Binary Student File

Page 5: 13-3   Converting File Type

Computer Science: A Structured Programming Approach Using C 5

PROGRAM 13-5 Text to Binary Student File

Page 6: 13-3   Converting File Type

Computer Science: A Structured Programming Approach Using C 6

PROGRAM 13-5 Text to Binary Student File

Page 7: 13-3   Converting File Type

Computer Science: A Structured Programming Approach Using C 7

PROGRAM 13-5 Text to Binary Student File

Page 8: 13-3   Converting File Type

Computer Science: A Structured Programming Approach Using C 8

PROGRAM 13-5 Text to Binary Student File

Page 9: 13-3   Converting File Type

Computer Science: A Structured Programming Approach Using C 9

FIGURE 13-15 Design for Print Student Data

Page 10: 13-3   Converting File Type

Computer Science: A Structured Programming Approach Using C 10

PROGRAM 13-6 Print Student Data

Page 11: 13-3   Converting File Type

Computer Science: A Structured Programming Approach Using C 11

PROGRAM 13-6 Print Student Data

Page 12: 13-3   Converting File Type

Computer Science: A Structured Programming Approach Using C 12

PROGRAM 13-6 Print Student Data

Page 13: 13-3   Converting File Type

Computer Science: A Structured Programming Approach Using C 13

PROGRAM 13-6 Print Student Data

Page 14: 13-3   Converting File Type

Computer Science: A Structured Programming Approach Using C 14

PROGRAM 13-6 Print Student Data

Page 15: 13-3   Converting File Type

Computer Science: A Structured Programming Approach Using C 15

PROGRAM 13-6 Print Student Data

Page 16: 13-3   Converting File Type

Computer Science: A Structured Programming Approach Using C 16

PROGRAM 13-6 Print Student Data

Page 17: 13-3   Converting File Type

Computer Science: A Structured Programming Approach Using C 17

PROGRAM 13-6 Print Student Data

Page 18: 13-3   Converting File Type

Computer Science: A Structured Programming Approach Using C 18

13-4 File Program Examples

This section contains two common file applications. This section contains two common file applications. The first uses the file positioning functions to The first uses the file positioning functions to randomly process the data in a file. The second merges randomly process the data in a file. The second merges two files.two files.

Random File ProcessingMerge Files

Topics discussed in this section:Topics discussed in this section:

Page 19: 13-3   Converting File Type

Computer Science: A Structured Programming Approach Using C 19

PROGRAM 13-7 Random File Application

Page 20: 13-3   Converting File Type

Computer Science: A Structured Programming Approach Using C 20

PROGRAM 13-7 Random File Application

Page 21: 13-3   Converting File Type

Computer Science: A Structured Programming Approach Using C 21

PROGRAM 13-8 Random File: Build File

Page 22: 13-3   Converting File Type

Computer Science: A Structured Programming Approach Using C 22

PROGRAM 13-8 Random File: Build File

Page 23: 13-3   Converting File Type

Computer Science: A Structured Programming Approach Using C 23

PROGRAM 13-9 Random File: Sequential Print

Page 24: 13-3   Converting File Type

Computer Science: A Structured Programming Approach Using C 24

PROGRAM 13-9 Random File: Sequential Print

Page 25: 13-3   Converting File Type

Computer Science: A Structured Programming Approach Using C 25

PROGRAM 13-10 Random File: Random Print

Page 26: 13-3   Converting File Type

Computer Science: A Structured Programming Approach Using C 26

PROGRAM 13-10 Random File: Random Print

Page 27: 13-3   Converting File Type

Computer Science: A Structured Programming Approach Using C 27

FIGURE 13-16 File Merge Concept

Page 28: 13-3   Converting File Type

Computer Science: A Structured Programming Approach Using C 28

ALGORITHM 13-1 Pseudocode for Merging Two Files

Page 29: 13-3   Converting File Type

Computer Science: A Structured Programming Approach Using C 29

PROGRAM 13-11 Merge Two Files

Page 30: 13-3   Converting File Type

Computer Science: A Structured Programming Approach Using C 30

PROGRAM 13-11 Merge Two Files

Page 31: 13-3   Converting File Type

Computer Science: A Structured Programming Approach Using C 31

PROGRAM 13-11 Merge Two Files

Page 32: 13-3   Converting File Type

Computer Science: A Structured Programming Approach Using C 32

PROGRAM 13-11 Merge Two Files

Page 33: 13-3   Converting File Type

Computer Science: A Structured Programming Approach Using C 33

13-5 Software Engineering

Any file environment requires some means of keeping Any file environment requires some means of keeping the file current. The function that keeps files current is the file current. The function that keeps files current is known as known as updating. To complete our discussion of . To complete our discussion of files, we discuss some of the software engineering files, we discuss some of the software engineering design considerations for file updating. design considerations for file updating.

Update FilesSequential File UpdateThe Update Program DesignUpdate ErrorsUpdate Structure Chart and Logic

Topics discussed in this section:Topics discussed in this section:

Page 34: 13-3   Converting File Type

Computer Science: A Structured Programming Approach Using C 34

FIGURE 13-17 Sequential File Update Environment

Page 35: 13-3   Converting File Type

Computer Science: A Structured Programming Approach Using C 35

FIGURE 13-18 File Updating Example

Page 36: 13-3   Converting File Type

Computer Science: A Structured Programming Approach Using C 36

FIGURE 13-19 Update Structure Chart

Page 37: 13-3   Converting File Type

Computer Science: A Structured Programming Approach Using C 37

ALGORITHM 13-2 Pseudocode for File Update