1 / 10

Lab guide # 10

Lab guide # 10. C File Processing Review & Lab assignments. Key points. Data hierarchy File & Stream Create, read, write and update: Sequential access file Random access file. Bit, bytes, characters, records, files database. Data hierarchy. File:

sforrester
Télécharger la présentation

Lab guide # 10

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Lab guide # 10 C File Processing Review & Lab assignments

  2. Key points • Data hierarchy • File & Stream • Create, read, write and update: • Sequential access file • Random access file

  3. Bit, bytes, characters, records, files database Data hierarchy

  4. File: • A sequence of bytes, ends with end-of-file marker • Structure • File descriptor • File control block • Stream: • Provide communication channel between files and programs • File pointer: to be returned when open a file • stdin, stdout, stderr • Read/Write function • fgets, fputc, fgets, fputs, fscanf, fprintf File & Stream

  5. Create FILE *cfPtr; cfPtr = fopen(“clients.dat", “w”); • Opening modes • Character mode: r,w,a,r+,w+,a+, • Binary mode: rb,wb,ab,rb+,wb+,ab+ Create, read, write and update

  6. Sequential vs. Random access file

  7. Fig. 11.8 Fig 11.12 Fig 11.15 Lab Assignment

  8. Hardware Store You are the owner of a hardware store and need to keep an inventory. 4. Lab Assignmentstion 11 Tool Record • The tool identification number should be the record number.

  9. Initialize the random-access file “hardware.dat” to 100 empty records. (ONLY if it was empty) • Menu • Input a tool data. • List all tools. • Delete a tool record. • Update a tool record. Program

  10. Use this information to start your file.

More Related