Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Give functionality to phone book.c by adding structures and functions. Structures: Create two structures personal info and phone book in a library header named libpb.h.

image text in transcribedimage text in transcribedimage text in transcribedimage text in transcribed

Give functionality to phone book.c by adding structures and functions. Structures: Create two structures personal info and phone book in a library header named libpb.h. The structure phone book holds an array of personal info with up to 20 entries (struct personal info [20]), as well as the number of people in the phone book (int num people). The maximum number of people in this phone book will be 20. The personal info structure will hold 3 character arrays, the first name (char first [25]), the last name (char last [25]), and the phone number (char phone [15]) Functions: 1: Write a function to add a contact (personal.info) to the phone book using the prototype below: void add person(struct phone.book * pb, struct personal info person); Add this prototype to libpb.h and the definition to libpb.c. Read the phone book.c carefully. The phone.book.c prompts the user to enter the information as seen in the sample output below. After the new contact information is entered, the program will call the function add person and pass this information to the function. In your function definition you need to add this new contact to the phone book. 2: Write a second function using the prototype below to search the phone book for a first name. Read the phone book.c carefully. The phone book.c prompts the user to enter a name to search for, and then it will pass this name to the function search pb. In your function definition you need to search for all the contacts that matches the searched first name and print full information of each contact that has the same fist name with the format shown in the sample output. void search pb(struct phone book pb, char find name ]) Hint: To compare two strings, include the string.h library in your libpb.c and use the function strcmp(char *, char *); no linker flags are needed for this library. stremp)O returns 0 (or false) if the strings are the same You can use !strcmp) to return true if they are the same. If there is no contact found, print 'No entries with that name. n' Sample output for the program: Give functionality to phone book.c by adding structures and functions. Structures: Create two structures personal info and phone book in a library header named libpb.h. The structure phone book holds an array of personal info with up to 20 entries (struct personal info [20]), as well as the number of people in the phone book (int num people). The maximum number of people in this phone book will be 20. The personal info structure will hold 3 character arrays, the first name (char first [25]), the last name (char last [25]), and the phone number (char phone [15]) Functions: 1: Write a function to add a contact (personal.info) to the phone book using the prototype below: void add person(struct phone.book * pb, struct personal info person); Add this prototype to libpb.h and the definition to libpb.c. Read the phone book.c carefully. The phone.book.c prompts the user to enter the information as seen in the sample output below. After the new contact information is entered, the program will call the function add person and pass this information to the function. In your function definition you need to add this new contact to the phone book. 2: Write a second function using the prototype below to search the phone book for a first name. Read the phone book.c carefully. The phone book.c prompts the user to enter a name to search for, and then it will pass this name to the function search pb. In your function definition you need to search for all the contacts that matches the searched first name and print full information of each contact that has the same fist name with the format shown in the sample output. void search pb(struct phone book pb, char find name ]) Hint: To compare two strings, include the string.h library in your libpb.c and use the function strcmp(char *, char *); no linker flags are needed for this library. stremp)O returns 0 (or false) if the strings are the same You can use !strcmp) to return true if they are the same. If there is no contact found, print 'No entries with that name. n' Sample output for the program

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

Transact SQL Cookbook Help For Database Programmers

Authors: Ales Spetic, Jonathan Gennick

1st Edition

1565927567, 978-1565927568

Students also viewed these Databases questions