Lisa b

Lisa b

  • 2k
  • 31
  • 14.5k

C program that deals with structures and arrays?

May 15 2013 8:23 PM

Set up a text file consisting of names and telephone numbers.  Some example lines are provided below.

Note that each name ends with a semi-colon with no spaces around the semi-colon.

Key John;09-41783

Baggins Bilbo;05-89378

 

Write a C program that includes the following:

·         A structure to store one name and one telephone number

·         An array of these structures called phonelist

·         The phonelist must be loaded from the file by using *exactly* this piece of code:

          i = 0;

          while (fgets(line, 200, f) != NULL) {

            phonelist[i] = getdetails(line);

            i++;

          }

·         At least three functions (including the function called getdetails)

 

The following menu must be displayed on the screen:

A. Search for a name

B. Display all names

Q. Quit

The program must perform the appropriate operations.  If B is selected, the names must be shown in alphabetical order.  Note that the names in the file are not in any particular order. should be easy to read


Answers (3)