I have typed in a program that shows two errors like this..
(1) Identifier 'searchfor' cannot have a type qualifier in function club::writeinto()
(2)Declaration missing ; in function club::writeinto()
my program..
//Program to help me #include<iostream.h>
#include<conio.h>
#include<math.h>
#include<stdlib.h>
#include<fstream.h>
#include<stdio.h>
#include<string.h>
#include<iostream.h>
class club
{int mno;
char activity[50];
public:
char memname[20];
void enterdata()
{
cout<<"Enter details";
cin>>mno>>memname>>activity;
}
void showdata()
{cout<<mno<<memname<<activity;
}
char*retname()
{
return memname;
}
void writeinto();
void searchfor();
void update();
void del();
void exit()
{
exit();
}
};
void club::writeinto()
{
club c;
{
ofstream fout("project.dat",ios::binary);
{
if (!fout)
{
cout<<"Error";
exit();
}
while(!fout.eof())
{
int N,i;
cout<<"Enter the number of records to be entered";
cin>>N;
{for(i=0;i<N;i++)
c.enterdata();
fout.write((char *)&c,sizeof(c));
}
fout.close();
}}}
void club::searchfor()
{
club c;
{
ifstream fin("project.dat",ios::binary);
if(!fin)
{
cout<<"Error";
}
while(!fin.eof())
{
char name[23];
cout<<"Enter the name";
cin>>name;
fin.read((char*)&c,sizeof(c));
{
if(strcmp(name,c.memname)==0)
c.showdata();
}
fin.close();
}}
void update()
{
club c;
char modname;int match=1;
fstream file("project.dat",ios::out|ios::in|ios::binary);
cout<<"Enter the name to be modified";
cin>>modname;
if(!file)
{
cout<<"Error";
}
while(!file.eof())
{
file.read((char*)&c,sizeof(c))
{ if(modname==c.memname())
{
c.enterdata();
}
file.seekp(-1*sizeof(c),ios::cur)
file.write((char*)&c,sizeof(c));
match=1;
else
match=0;
}}
if(match==0)
cout<<"Sorry,Match not found";
}
file.close();
}
void del()
{ club c;
char del[24];
ofstream fout("temp.dat",ios::binary);
ifstream fin("project.dat",ios::binary);
if(!fin)
{
cout<<"Error";
}
if(!fout)
{
cout<<"Error";
}
while(!fin.eof())
{
while(fin.read(char*)&c,sizeof(c))
{ c.Display();
if(c.returnname()!=del)
fout.write((char*)&c,sizeof(c));
fin.close();
fout.close();
remove("project.dat");
rename("temp.dat","project.dat");
}
//Void main Program
void main()
char user[25],password[25],cnt, option;
club c2;
cout<<"Enter username";
cin>>user;
cout<<"Enter password";
cin>>password;
if(strcmp(user,"student")&&strcmp(password,"1234") ==0)
{
cout<<"Login successful!";
cout<<""<<"Hello! Welcome to the Club page for members"<<""<<'\t';
cout<<""<<"MENU"<<""<<'\t';
cout<<""<< "Choose any option to proceed!"<<"";
do
{
cout<<""<<"1."<<""<<""<<"Add a new record"<<""<<""<<'\t';
cout<<""<<"2."<<""<<""<<"Search for a record"<<""<<""<<'\t';
cout<<""<<"3."<<""<<""<<"Update a record"<<""<<""<<'\t';
cout<<""<<"4."<<""<<""<<"Delete a record"<<""<<""<<'\t';
cout<<""<<"5."<<""<<""<<"Exit"<<""<<""<<'\t';
switch(option)
{
case 1:c2.writeinto();
break;
case 2:c2.searchfor();
break;
case 3:c2.update();
break;
case 4:c2.del();
break;
default:exit(0);
}
cout<<"Do you want to continue";
cin>>cnt;
while(option<4||cnt=="Y")
}
else
{
cout<<"Sorry,try again";
break;
}}
}
There is no void main...
Pls. reply asap
thanks a lot