How to make a telephone directory????

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • yenra
    New Member
    • Sep 2006
    • 5

    How to make a telephone directory????

    Can anyone help me in making this program?!...

    I need to make a telephone directory using structure definition..

    typedef struct AddressTag{
    char surname[55];
    char givenname[55];
    char middleinitial[5];
    char telnum[55];
    struct PersonTag *next;
    } AddType;

    I need to have function for inserting, editing and deleting an entry.Entries should be inserted in alphabetical order according to the person's surname.It should also be able to save the entries to a file..
  • D_C
    Contributor
    • Jun 2006
    • 293

    #2
    typedef struct AddressTag{
    char surname[55];
    char givenname[55];
    char middleinitial[5];
    char telnum[55];
    struct PersonTag *next;
    } AddType;

    Is this supposed to be a linked list? If your struct is AddressTag, what does PersonTag have to do with it? Where is that defined?

    Until we know a PersonTag is, I'm not sure we can help you yet.

    Comment

    • yenra
      New Member
      • Sep 2006
      • 5

      #3
      Originally posted by D_C
      typedef struct AddressTag{
      char surname[55];
      char givenname[55];
      char middleinitial[5];
      char telnum[55];
      struct PersonTag *next;
      } AddType;

      Is this supposed to be a linked list? If your struct is AddressTag, what does PersonTag have to do with it? Where is that defined?

      Until we know a PersonTag is, I'm not sure we can help you yet.
      >
      sori, I made a mistake. it should be struct AddressTag *next..
      ..pls help me..I really had a dificulty in doing this..

      Comment

      • yenra
        New Member
        • Sep 2006
        • 5

        #4
        Really need help in making my address book program...

        How to make a telephone directory????
        --------------------------------------------------------------------------------

        Can anyone help me in making this program?!...

        I need to make a telephone directory using structure definition..

        typedef struct AddressTag{
        char surname[55];
        char givenname[55];
        char middleinitial[5];
        char telnum[55];
        struct AddressTag *next;
        } AddType;

        I need to have function for inserting, editing and deleting an entry.Entries should be inserted in alphabetical order according to the person's surname.It should also be able to save the entries to a file...

        Comment

        • yenra
          New Member
          • Sep 2006
          • 5

          #5
          help!!!how to work with linked list and file???

          ..please, I really need help..I have a hard time understanding this topic.. I don't know how to implement this. I need to make a program of an address book using this structure definition in C...

          typedef struct AddTag{
          char surname[100];
          char firstname[100];
          char address[100];
          char tel_no[50];
          struct AddTag *link;
          } AddType;
          AddType *List //list of entries
          ..I need to have a function for inserting entries in Alphabetical Order, editing entries, saving to a file and retrieving entries from a file...
          ..

          Comment

          • Banfa
            Recognized Expert Expert
            • Feb 2006
            • 9067

            #6
            Please stop reposting the same topic.

            You are trying to set up a linked list. In it's simplest form you start with a pointer to the first item. When you need to add a new item you allocate the memory (using malloc or new) fill in your structure and then make you new structure next pointer equal to the current first pointer and the then the first pointer point to the new structure.

            Code:
            AddType *pFirst = NULL;
            
            void AddItem()
            {
                AddType *pNewAdd = new AddType;
            
                pNewAdd->link = pFirst;
                pFirst = pNewAdd;
            }
            You can list all the items by just taking apointer starting at the first item and itterating down the list until you get to NULL

            Code:
            void PrintList()
            {
                AddType *pCurrent;
            
                for(pCurrent=pFirst; pCurrent != NULL; pCurrent=pCurrent->link)
                {
                    // output data in pCurrent
                }
            }
            Deleting at the begining of the list involves moving the first pointer onto the next item in the list and then delting the memory that it pointed to

            Code:
            void DeleteFirst()
            {
                AddType *pDelete = pFirst;
            
                if (pDelete != NULL)
                {
                    pFirst = pFirst->link;
                    delete pDelete;
                }
            }

            Comment

            Working...