Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

. Please can write C language . Also can you add the with code , not code photos please. Thanks a lot https://drive.google.com/open?id=1JdvzO9gFxuVs5Mkvhu0tc3fUT6Ekp0ln . library.bin



Please can write C language . Also can you add the with code  , not code photos please. Thanks a lot 

https://drive.google.com/open?id=1JdvzO9gFxuVs5Mkvhu0tc3fUT6Ekp0ln  . library.bin on the link

You are given a binary file library.bin (you can download from Moodle) which contains records of books in a library. Each book record will be stored using bookData struct. typedef struct { int id; // book id char name[20]; // book name char author[20]; // author of book int quantity; // quantity of book int rackno; // rack no of the book } bookData; Library.bin file consists of 100 records. 96 of them are blank records. The other 4 records (not blank) are placed in specific positions of the binary file based on their ids. For example, if id of the book is 5, its record is the fifth record in the file. The size of each record is equal to the size of bookData struct. The records are sorted according to their id number. Implement the following functions: void showRecords(0 - It shows and lists all records in the binary file. int updateRecord(int id, int diff) - This function updates quantity of the book whose id is provided in the parameter id. The update is performed by adding the number in the parameter diff to the quantity of the book with the given id. If there is a book record with the given id, the new quantity of the book is written to library.bin and the function returns 1; otherwise, it returns 0. int deleteRecord(int id) - This function removes the book with the given id from binary file (library.bin) by setting its fields to {0, "", " o, 0). If the given id is found in the binary file, the book record will be removed from the binary file and the function returns 1; otherwise, it returns 0. A skeleton code (lab5pre_skeleton.c) provided in Moodle. Note that, in each function, you should open library.bin, perform your task, and close the file. In showRecords fuction, open the file with "rb", in updateRecord and deleteRecord function open the file with "rb+". Hint: fseek() is used to move file pointer associated with a given file to a specific position. You need to use fseek () function to add, update and delete any record in binary file.

Step by Step Solution

3.40 Rating (153 Votes )

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Understanding Basic Statistics

Authors: Charles Henry Brase, Corrinne Pellillo Brase

6th Edition

978-1133525097, 1133525091, 1111827028, 978-1133110316, 1133110312, 978-1111827021

More Books

Students also viewed these Programming questions