1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Use C program to write a simple address book:

Discussion in 'C' started by johnjrgs, Feb 15, 2013.

  1. johnjrgs

    johnjrgs New Member

    Joined:
    Feb 10, 2013
    Messages:
    1
    Likes Received:
    0
    Trophy Points:
    0
    Occupation:
    Student
    Location:
    Philippines
    OVERVIEW:
    Create a simple address book program that stores the first name, last name, student number, degree program, mobile number and email address of a student. The program will have five possible actions:add a new entry, edit an existing entry, delete an existing entry, list all entries, and close the program.The program should keep asking for the next action until the user closes the program.
    CONSTRAINTS:
    • Aside from your own functions, you are only allowed to use the functions in the following
    libraries:
    • stdio.h
    • ctype.h
    • string.h
    There should be a macro in your code defining the number of entries in your address book. The
    maximum allowable number of entries is 30.
    There should be no recursive functions.
    The inputs should have the following error checking capabilities:
    • first name, last name, degree program: can only contain letters and spaces, max of 20, at
    least one character
    • student number: can only contain digits and a dash, format is xxxx-yyyyy
    • mobile number: can only contain digits, format is 09xxyyyyyyy
    • email: can only contain letters, digits, underscores, dots, and @, max of 30
    Implement this using only the concepts discussed from lectures 1 to 8a.

    So far the code that I have written is here:

    Code:
    #include <stdio.h>
    #include <string.h>
    #define max_num 30
    
    void add_contact();
    void edit_contact();
    void del_contact();
    void list_contact();
    
    int main()
    {
    
    char mode, size;
    char addressbook[6][30][30];
    
        printf("Select the mode you want\n");
        printf("1 -> Add contact\n"); 
        printf("2 -> Edit contact\n");
        printf("3 -> Delete contact\n");
        printf("4 -> List contact\n");
        printf("5 -> Exit the program\n");
        scanf("%c", &mode);
        
        switch(mode){ //switch (determine which action to take
        
        case 1:
        add_contact();
        break
        case 2:
        edit_contact();
        break;s
        case 3:
        del_contact();
        break;
        case 4:
        list_contact();
        break;
        } //end switch
        return 0;   
    }
    
    
    My problem is how to make the functions' body. Please help me..
    I also need to keep track of the input since the max number of entries is 30. I don't know how to do that though.
     

Share This Page