Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

It need to be written in C. And, please write it with different logic than it was written in chegg questions(because there is already two

It need to be written in C. And, please write it with different logic than it was written in chegg questions(because there is already two answers in chegg and it is interesting to me how to write it another way). Thanks in advance Task: Create a phone book application in C. A phone book can store a list of (name, phone number) pairs.

Represent an entry with a struct of a name and a phone number. The name and the phone number should both be 30 character arrays.

Represent a phone book with a structure that contains a pointer to an array of entries, the number of inserted elements and the actual size of the array.

Create an init() function which initializes the phone book. This function has an integer parameter which determines the size of the entries' array. An array with this size should be allocated on the heap memory. Don't forget to implement a corresponding destroy() in order to avoid memory leak.

Create an insert() function which is given a name and a phone number. These should be inserted to the phone book. If the name is already in the phone book then the person's phone number should be updated. The insert() function should return a boolean value depending on whether the insertion was successful. The insertion is not successful if the array is full.

Create a get() function which is given a name and returns the phone number of this person. If the person is not found in the phone book then NULL pointer should return.

Create a print() function which prints all entries of the phone book.

Create a dump() function which prints all entries to a text file. The text file's name should be given as a parameter to this function.

In the main() function demonstrate the usage of all functions. Create a phone book, insert a few entries and print its content to the screen and a text file.

Make sure to avoid any undefined behavior in the program. In case of compilation error, the assignment automatically scores 0 points. Sample output:

Step by Step Solution

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

Power Bi And Azure Integrating Cloud Analytics For Scalable Solutions

Authors: Kiet Huynh

1st Edition

B0CMHKB85L, 979-8868959943

More Books

Students also viewed these Databases questions