Welcome to Software Development on Codidact!
Will you help us build our independent community of developers helping developers? We're small and trying to grow. We welcome questions about all aspects of software development, from design to code to QA and more. Got questions? Got answers? Got code you'd like someone to review? Please join us.
Post History
My advice to you is to break this down into smaller problems and try to solve them one at a time, making sure you have a program that can compile and run at each step. First: figure out how to suc...
Answer
#1: Initial revision
My advice to you is to break this down into smaller problems and try to solve them one at a time, making sure you have a program that can compile and run at each step. First: figure out how to successfully read and write a single book. Write a function that reads book information from stdin and returns a `struct book`. Write another function that accepts a `struct book` as an argument and writes all that information to a file somehow. Write a third function that reads from that file and returns a `struct book`. Write a fourth function that accepts a `struct book` and prints its information to stdout. You should be able to write a program that uses these four functions and prints the same information, in the same order, that you give it. (Based on the state of your code and the questions you've asked so far, I suspect this is the hard part for you—it has nothing to do with the deleting operation.) Second: now figure out how to successfully read and write an entire library. Adapt the above functions to handle `struct library *` pointers instead of `struct book` values, and test your program again to make sure that it prints what you give it. Third: figure out how to write a function that edits a `struct library *` in the way that you want. You can do this either by accepting and returning `struct library *` pointers, or just by accepting a `struct library **` double pointer. This function should do *nothing* with files or with `scanf` (you can use `printf` if it helps you understand what's going on). Test this function by incorporating it into the program you wrote in the second part. If it doesn't work the way you expect, revisit the function.