tags:

views:

13

answers:

0

We are suppose to create a phonebook application that has about eight options. Add a user, display a user, sort the users, display users randomly, find users randomly, delete users. This is what I have so far.

include

include

include

//Functions

void addUser(); void displayUser(); void sortUser(); ... //*****Data Structure*************

typedef struct { char firstName[20]; char lastName[30]; int number;

     }phonebook;


    //Declaration of pointer struct

     entry *pb;


      //Variable Initialization Dictionary

int count = 0;
int delCount = 0;
int y = 0;
int j = 0;
int x = 0;
int iSort = 0; 
char nFind[30] = {'\0'};

//**************Main Function*****************
main()
{ int userValue = 0; while (userValue !=8) { Menu...

        printf("Choose an option: ");
        scanf("%d", &userValue);

        //end of displayed menu

        //switch statement

...

void sort() { system("cls");

    int i = 0;
    int j = 0;
    int tAlpha = 0;

  if (count == 0)
    {
     printf("\n\n ***Empty phonebook.***  \n\n Select (Option 1: Add Entry) to add an entry to the phonebook.\n\n");
     }

     else  

         for (i = 0; i <(count - 1); i--) 
             for (j = 1; j <= i; j++)
{ 
       if (strcmp(pbEntry[j-1].fName, pb[j].fName > 0)

                   tAlpha = pb[j-1];
                   pb[j-1] = pb[j];
                   pb[j] = tAlpha;


            printf("%s %s \t %d\n\n\n", pb[i].fName, pb[i].lName, pb[i].tele);
                }

                   }
                   }
                   }

} //end of sort()

I know it is a fuzzy, but I am lost as what to do. How do I sort all the names the user inputs into the application? Do I use some of the logic for displaying the names and phone numbers in the program? I really appreciate any help! Thanks.