k i have those errors fixed and my program compiles but now for some reason i cant get past the first call function here's the full code (its quite big)
Code:
#include <iostream.h>
#include <string.h>
#include <fstream.h>
#include <stdio.h>
#include <conio.h>
//-----------------------------------
#define Voters 10
class people
{
public:
struct details
{
char name[20];
char phone[20];
char address[100];
char email[30];
char party[20];
}np[Voters];
void clearary(void);
void enter(int);
void list(void);
};
class store: public people
{
public:
void save(void);
void load(void);
void findF(void);
void findA(void);
void findT(void);
void findE(void);
void findP(void);
};
char name[12]="terry young";
//------------------------------------
int main (void)
{
people datab;
store tdata;
char any;
char choice;
char choice2;
float count = 0;
float count2 = 0;
int c;
tdata.clearary();
cout<<"\nThis program will allow the user to create and then control a database. \n";
cout<<"what would you like to do? \n To enter a new record press n \n"
"To delete a record press d \nTo view a full list of the users with details press f \n"
"To view serch options press s\n to quit press q :- ";
cin>>choice;
while(count == 0)
{
choice = getchar ();
switch(choice)
{
case 'n':
{ tdata.enter(1);
tdata.save();
count = 1;
break;
}
case 'd':
{
//delete a record ??
count = 1;
break;
}
case 'f':
{
tdata.list();
count = 1;
break;
}
case 's':
{
cout<<"search options \n";
cout<<"what would you like to do? \nTo search for full contact details press F \n"
"To search for addresses press A \n"
"To search for telephone numbers press T \n"
To search for email address press E\n"
To search for the members of a politial party press P\n"
To quit press Q :- ";
cin>>choice2;
while(count2 = 0)
{
choice2 = getchar ();
switch(choice2)
{
case 'F':
{
tdata.findF();
count2 = 1;
break;
}
case 'A':
{
tdata.findA();
count2 = 1;
break;
}
case 'T':
{
tdata.findT();
count2 = 1;
break;
}
case 'E':
{
tdata.findE();
count2 = 1;
break;
}
case 'P':
{
tdata.findP();
count2 = 1;
break;
}
case 'Q':
{
count2 = 1;
break;
}
} //end of switch
count = 1;
break;
}
case 'q':
{
count = 1;
break;
}
} //end of switch
}
any = getch();
return(0);
}// end of main
}
void people::clearary(void)
{
int i;
cout << " Clearing array..";
for(i=0;i<Voters;i++)
{
*np[i].name='\0';
*np[i].phone='\0';
*np[i].address='\0';
*np[i].email='\0';
*np[i].party='\0';
}
}
//..........................................
void people::enter(int i)
{
char k = 'y';
while (k == 'y');
{
cout << "Enter the name of the person ";
gets(np[i].name);
cout << "Enter the phone number of the person ";
gets(np[i].phone);
cout << "Enter the full address of the person ";
gets(np[i].address);
cout << "Enter the Email address of the person";
gets(np[i].email);
cout << "enter the name of the party that the person belongs to ( conservative, labour, liberal, other)";
gets(np[i].party);
cout << "Do you wish to enter another member ? (y/n)";
cin >> k;
}
}
// end of enter member function
//*******************************************************************************
void store::save(void) {
fstream outfile;
int i;
cout << "Saving.." << endl;
outfile.open("c:\\quincy2002\\tel.dat",ios::out);
for(i=0;i<Voters;i++) {
outfile.write((char *) &np[i],sizeof(class people));
}
outfile.close();
}//end of save member function.
//*******************************************************************************
void store::load(void) {
fstream infile;
int i;
cout << "Loading.." << endl;
infile.open("c:\\quincy2002\\tel.dat",ios::in);
for(i=0;i<Voters;i++) {
infile.read((char *) &np[i],sizeof(class people));
}
infile.close();
}//end of load member function.
//********************************************************************************
void people::list(void)
{
int i;
cout << "Listing.." << endl;
for (i=0;i<13;i++)
{
cout << "\nName " << np[i].name << endl;
cout << "\nPhone No " << np[i].phone << endl;
cout << "\nAddress " << np[i].address <<endl;
cout << "\nEmail " << np[i].email <<endl;
cout << "\nPolitical Party " << np[i].party <<endl;
}//end of for loop
}// end of list member fuction.
//********************************************************************************
void store::findF(void)
{
int i = 0;
bool serch = false;
char person[20];
cout << "please enter the name of the person you wish to find their details : ";
gets(person);
for(i = 0; i < Voters; i++)
{
if(!strcmp(np[i].name, person))
{
cout << "Eurkia \n" << np[i].name << "\n" << np[i].phone << "\n"
<< np[i].address << "\n" << np[i].email << "\n" << np[i].party ;
serch = true;
}
}
if(serch == false)
{
cout << "Sorry record not found.";
}
}
//*****************************************************************************************
void store::findA(void)
{
int i = 0;
bool serch = false;
char person[20];
cout << "please enter the name of the person you wish to find their address : ";
gets(person);
for(i = 0; i < Voters; i++)
{
if(!strcmp(np[i].name, person))
{
cout << "Eurkia \n" << np[i].name << "\n" << np[i].address;
serch = true;
}
}
if(serch == false)
{
cout << "Sorry record not found.";
}
}
//***************************************************************************************************
void store::findT(void)
{
int i = 0;
bool serch = false;
char person[20];
cout << "please enter the name of the person you wish to find their phone number : ";
gets(person);
for(i = 0; i < Voters; i++)
{
if(!strcmp(np[i].name, person))
{
cout << "Eurkia \n" << np[i].name << "\n" << np[i].phone ;
serch = true;
}
}
if(serch == false)
{
cout << "Sorry record not found.";
}
}
//*********************************************************************************************************
void store::findE(void)
{
int i = 0;
bool serch = false;
char person[20];
cout << "please enter the name of the person you wish to find their email address : ";
gets(person);
for(i = 0; i < Voters; i++)
{
if(!strcmp(np[i].name, person))
{
cout << "Eurkia \n" << np[i].name <<"\n" << np[i].email ;
serch = true;
}
}
if(serch == false)
{
cout << "Sorry record not found.";
}
}
//********************************************************************************************
void store::findP(void)
{
int i = 0;
bool serch = false;
char fParty[20];
cout << "please enter the name of the party you wish to find (conservitive, labour, libral or other) : ";
gets(fParty);
for(i = 0; i < Voters; i++)
{
if(!strcmp(np[i].party, fParty))
{
cout << "Eurkia \n" << np[i].name << "\n" << np[i].party ;
serch = true;
}
}
if(serch == false)
{
cout << "Sorry record not found.";
}
}
//*************************END************************************************************************
also i have to add the load function in here somewere (the functions writen just not sure were to call it)
so can any one help
(also im using Quincy to write and compile it)