423,335 Members | 1,149 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 423,335 IT Pros & Developers. It's quick & easy.

Coding help please!!

Kindle Life 123
P: 6
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
5 Days Ago #1
Share this Question
Share on Google+
1 Reply


weaknessforcats
Expert Mod 5K+
P: 9,163
Start with simpler code.

Like this:

Expand|Select|Wrap|Line Numbers
  1. class club
  2. {
  3.  
  4. };
  5.  
  6. int main()
  7. {
  8.  
  9.    club c;
  10. }
Get this to compile.

Then add ONE thing. Like a data member or a member function.

Then recompile and get that working.


This way when there's an error it will be in the last code you entered. Rather than fix errors, it's better to keep errors out in the first place.


What you posted has a lot of errors that I can see.
5 Days Ago #2

Post your reply

Sign in to post your reply or Sign up for a free account.