Thread: Records. *look*

  1. #1
    Registered User SavesTheDay's Avatar
    Join Date
    Jan 2002

    Records. *look*

    well here is my problem....this might be a bit hard to explain.....we have a structure containing the 3 fields firstname, lastname, and phonenumber.....the program we are making is like an address book....when the user inserts a new entry, it's supposed to insert in the first blank if you have 4 records...but you went back and deleted record 3.....when it prints it would print Record 1, Record 2, Record 4...but then if you were to insert another record, it would fill in Record 3 instead of Record 5....make sense? When a record is deleted, all that happens is the lastname field of that record is set to "00", so it won't print when an "00" lastname comes up....heres what we have tried:

    case 'I':
    case 'i':
         int x, y;
         for (x=0; x<rnumber; x++)            // rnumber is the number of records //
             if (y==1)
                  x=rnumber;         //  so the loop will stop //
         if (x<=rnumber)
    this just isn't working....the "insert(&roster[rnumber++]);" works fine all by itself to insert to the next record....the code above is suppose to check every record to see if any of the lastnames are equal to "00", and if they are , it's supposed to insert the record there, quit the for loop, and NOT run the other insert.......any ideas?

  2. #2
    Confused Magos's Avatar
    Join Date
    Sep 2001
    The return value from strcmp(). According to my help files, strcmp returns 0 if the two strings are equal, not 1 as in your program. That might be your problem.

    Give a man a fish and you feed him for a day.
    Teach a man to fish and you feed him for a lifetime.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 26
    Last Post: 07-05-2010, 10:43 AM
  2. reading a file into a block
    By mickey0 in forum C++ Programming
    Replies: 19
    Last Post: 05-03-2008, 05:53 AM
  3. Counting number from a random file
    By kamisama in forum C Programming
    Replies: 42
    Last Post: 02-22-2005, 05:16 PM
  4. display records held in a struct
    By colinuk in forum C Programming
    Replies: 3
    Last Post: 02-02-2005, 07:51 AM
  5. For loop ; printing records
    By Prezo in forum C Programming
    Replies: 3
    Last Post: 09-15-2002, 06:38 AM