Question: phone_book.c #include #include #include libpb.h int main () { char cont; char find_name[25]; struct phone_book pb; pb.num_people = 0; struct personal_info person; printf( ********************************************* );

 phone_book.c #include #include #include "libpb.h" int main () { char cont;char find_name[25]; struct phone_book pb; pb.num_people = 0; struct personal_info person; printf("

phone_book.c

#include #include #include "libpb.h"

int main () { char cont; char find_name[25]; struct phone_book pb; pb.num_people = 0; struct personal_info person;

printf(" ********************************************* "); printf(" Start with entering new contacts! "); printf(" ********************************************* "); printf(" Would you like to enter a new contact (Y/N): ");

while(pb.num_people

if (cont == 'Y') { printf("Enter a first name: "); scanf("%s", person.first); printf("Enter %s's last name: ", person.first); scanf("%s", person.last); printf("Enter %s's phone number: ", person.first); scanf("%s", person.phone); add_person(&pb, person);} else if (cont == 'N') break; else if (cont == ' ') continue; else printf("Error: User entered '%c'. Must enter either 'Y' or 'N' ", cont); printf(" Would you like to enter a new name (Y/N): ");

}

//search phone book by first name and print persons

printf(" ********************************************* "); printf(" Now You can search for names! "); printf(" ********************************************* "); printf(" Would you like to search for a name (Y/N)? ");

while(1){ scanf("%c", &cont); if (cont == 'Y'){ printf("Enter a person's name to search for: "); scanf("%s", find_name); //scanf("%c", &tmp); search_pb(pb, find_name);} else if (cont == 'N') break; else if (cont == ' ') continue; else printf("Error: User entered '%c'. Must enter either 'Y' or 'N' ", cont); printf(" Would you like to search for a name (Y/N)? ");

} return 0; }

Need libpb.c and libpb.h

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 personalinfo 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 J); 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. strcmp() 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. . Sample output for the program

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!