#include<iostream>
#include<conio.h>
#include<stdio.h>
#include<cstring>
using namespace std;
int i, j;
struct info
{
char name[20];
int number;
};
void addcontact(info contactlist[]);
void editcontact(info contactlist[]);
void deletecontact(info contactlist[]);
void showallcontact(info contactlist[]);
void exit(info contactlist[]);
void menue(void);
void main()
{
menue();
}
void menue(void)
{
cout << "_______________________n";
cout << " PHONE BOOK n";
cout << "_______________________n";
cout << "1-Add Contactn";
cout << "2-Edit Contactn";
cout << "3-Delete Contactn";
cout << "4-Show All Contactsn";
cout << "5-Exitn";
int option;
cin >> option;
if (option == 1)
{
void addcontact(info contactlist[]);
}
else if (option == 2)
{
void editcontact(info contactlist[]);
}
else if (option == 3)
{
void deletecontact(info contactlist[]);
}
else if (option == 4)
{
void showallcontact(info contactlist[]);
}
else if (option == 5)
{
void exit(info contactlist[]);
}
}
void addcontact(info contactlist[])
{
i = 0;
system("CLS");
cout << "Welcome to Add contact sectionn";
cout << "Enter namen";
cin >> contactlist[i].name;
cout << "Enter numbern";
cin >> contactlist[i].number;
cout << "Contact Addedn";
i = i + 1;
if (i == 19)
{
cout << "Contact limit reachedn";
}
menue();
}
void editcontact(info contactlist[])
{
int flag = 0;
int k;
char name[20];
system("CLS");
cout << "Welcome to Edit contact sectionn";
cout << "Enter name to editn";
cin >> name;
for (int k = 0; k < 20; k++)
{
if (strcmp(name, contactlist[k].name) == 0);
{
flag = 1;
break;
}
}
if (flag == 1)
{
cout << "Enter a new namen";
cin >> contactlist[k].name;
cout << "Contact Editedn";
menue();
}
else if (flag != 1)
{
cout << "No record foundn";
}
}
void deletecontact(info contactlist[])
{
char name[20];
cout << "Enter name of contact to be deleted" << endl;
cin >> name;
for (int i = 0; i < 20; i++)
{
if (strcmp(name, contactlist[i].name) == 0)
{
strcpy(contactlist[i].name, " ");
cout << "contact deletedn" << endl;
menue();
}
}
}
void showallcontacts(info contactlist[])
{
int l;
cout << "detailsn";
for (l = 0; l < 20; l++)
{
cout << contactlist[l].name << endl;
cout << contactlist[l].number << endl;
menue();
}
}
void exit()
{
exit(0);
}
问问题
145 次