#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);
}
Asked
Active
Viewed 147 times
-7

Tuntuni
- 481
- 1
- 7
- 19

Sharan Gohar
- 3
- 1
-
3Your program has basic mistakes. How to call a function, for example. Please pick a book from [The Definitive C++ Books List](http://stackoverflow.com/questions/388242/the-definitive-c-book-guide-and-list) and start reading. – Mahesh Jul 24 '13 at 17:59
-
What is your question? – Lightness Races in Orbit Jul 24 '13 at 18:12
1 Answers
3
Your code does not make any sense. There are many problems with what you have written
I'm not going to go through them all, but the most glaring is
if (option == 1) {
void addcontact(info contactlist[]);
}
This is not how a function is called. Instead, it should look like
if (option == 1)
{
addcontact(x);
}
where X is an "info" type of object, which you don't have defined.
I'd strongly suggest finding some basic programming tutorials to get a better familiarity with what you are doing.

bengoesboom
- 2,119
- 2
- 23
- 27