c programming

Discussion in 'C' started by imported_shakeel, Jan 21, 2012.

  1. imported_shakeel

    imported_shakeel New Member

    Joined:
    Jan 21, 2012
    Messages:
    2
    Likes Received:
    0
    Trophy Points:
    0
    can any help me out of this program
    write a program to accept details of 5 customer number name and mobile numbe create a menu with option modify,display exit write function modify which will allows modification of mobile number and function display which will display all the details of customer and exit function is to close the program.
    plz help
    i would be very thankful:(
     
  2. hobbyist

    hobbyist New Member

    Joined:
    Jan 7, 2012
    Messages:
    141
    Likes Received:
    0
    Trophy Points:
    0
    you really will learn more by trying... :) as for the program, I'd try an array of structures.

    maybe your data could look something like

    Code:
    typedef struct {
       char name[20];
       char number[20];
    } data;
    
    
    to modify the names / numbers / etc maybe a function like

    Code:
    
    void updateRecord(data *record) {
    
       /* bits of code */
    }
    declare an array of structs

    Code:
    
       data records[5] = { { "name 1", "number 1" },
                                  { "name 2", "number 2" },
                                  { "name 3", "number 3" },
                                  { "name 4", "number 4" },
                                  { "name 5", "number 5" } };
    
    call your function

    Code:
    updateRecord(&records[index]); /* if working on one record */
    updateRecord(records) /* if working on the entire array */
    
    with the function, you may also want to pass along how many records there are, so you could add a parameter for that.

    Code:
    updateRecord(data *rec, int count) {
       /* bits of code */
    }
    
    and the call
    
    updateRecord(records, 5);
    
    you'd probably not want to use name N and number N, but just to give you an idea. try to not get lost in the details; work on little steps at a time.

    the menu is just a big loop requesting input; how you make the loop is up to you, but watch out for mixing data types and input functions as you may run into unexpectedly storing newlines into subsequent variables. in my opinion, stick with fgets for all input and convert as needed.

    give that program a shot.

    HTH
     
  3. herby

    herby New Member

    Joined:
    Jan 6, 2012
    Messages:
    9
    Likes Received:
    0
    Trophy Points:
    0
    i like yo code hobbyist and there is one i did so if he still needs the whole 'code like stuff' i could help pls shabbir if so let mi know.
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice