• 0

[C] Simple Address book program


Question

I am working on an assignment to create an simple address book program with C. I am trying to figure out how to set the amount of contacts that can be entered into the program. The assignment says that there can only be 10 entries. Does anyone know who to do this? any help would be appreciated. Thanks.

/*Program is an extremely simple address book
The Purpose of this program is to keep a list (an array) of 10 contact records (struct). Each record has a 10 character name field (char[]) and an age field (int).
The functionalities of the program should be made avaliable for end users through a menu that gives the following options(1. List Contacts, 2.Add a Contact, 3.Search by name, 4.Search by age, 5.Exit
When the user selects option 1, the program should list all cotacts in the array
When te user selects option 2, if the list is not full, the program should ask the user to input contact name then contact age. Otherwise, a message will be displaed informing the user that the list is full
For option 3 and 4, the program will ask the user to enter a name or age and list all contacts matching the given piece of data.
Unless the user chooses option 5, the program should keep running all the time.
*/
#include <stdio.h>

struct addressbook {char name[10]; int age;};


void List_Contacts()
{


}

void Add_a_Contact()
{


}

void Search_by_name()
{

}

void Search_by_age()
{

}

int main()
{
	int select = 0;
	while(select != 5)
	{
		printf("Select one of the following:\n");
		printf("1. List Contacts\n");
		printf("2. Add a contact\n");
		printf("3. Search by name\n");
		printf("4. Search by age\n");
		printf("5. EXIT\n");
		printf("Enter the number for what you wish to do\n");
		scanf_s("%d", &select);
		if(select == 1)
		{

		}
		if(select == 2)
		{


		}
		if(select == 3)
		{

		}
		if(select == 4)
		{

		}
		if(select == 5)
		{
			break;

		}

	}
return 0;
}

Link to comment
https://www.neowin.net/forum/topic/665356-c-simple-address-book-program/
Share on other sites

2 answers to this question

Recommended Posts

This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.