Structure Problem

This is a discussion on Structure Problem within the C++ Programming forums, part of the General Programming Boards category; I have 3 files for the program attached. The program works; however, I do have 2 potential problems with it: ...

  1. #1
    Registered User
    Join Date
    Oct 2001
    Posts
    37

    Structure Problem

    I have 3 files for the program attached. The program works; however, I do have 2 potential problems with it:

    1) When I add files to the Personal Information Manager (PIM) structure and then print it everything is fine. When I go back to add more files (before exiting the program) I can add more files, these new files overwrite what was in the structure instead of appending to it WHY?????

    2) The 2nd and biggest and more difficult problem is that I have to add a function that will allow me to search the records and delete a record that is selected. The record to be deleted can be any record, first, last, or any in between. Other than a linked list is this possible.

    I have searched and can find no inforamtion so far that will allow this except a linked list.

    Any suggestions, many thanks in advance.

    Alan
    Attached Files Attached Files

  2. #2
    Registered User
    Join Date
    Oct 2001
    Posts
    2,934
    Assuming count contains the number of entries, this will make it append instead of overwriting the previous entries.
    Code:
    int add_contact(contact *c, int count)
    {
        char lname[13];
        char fname[11];
        char mi[2];
     
    	char city[16];
    	char state[3];
    	char zip[6];
    	
     
        // Loop to count records and ensure the number of entries does not
    	// exceed the MAX_CONTACT limit.
    
        //for (int i = 0; i < MAX_CONTACT; i++)
        //Change this to:
        for (int i = count; i < MAX_CONTACT; i++)
        {

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. problem getting structure to work in my function
    By Tom Bombadil in forum C Programming
    Replies: 18
    Last Post: 05-28-2009, 10:53 AM
  2. Problem with structure and class
    By Bargi in forum C++ Programming
    Replies: 3
    Last Post: 09-25-2007, 03:30 AM
  3. Problem with arrays inside a structure
    By babu in forum C Programming
    Replies: 4
    Last Post: 07-12-2007, 10:35 AM
  4. accessing structure pointer problem
    By godhand in forum C Programming
    Replies: 2
    Last Post: 04-09-2004, 11:52 PM
  5. Problem checking for numeric value in a structure
    By ronkane in forum C++ Programming
    Replies: 4
    Last Post: 01-20-2002, 02:53 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21