Hi everyone... I am a new member... I have very basic knowledge in c++... I use borland c++ 5.5... I am in my 12th grade...
I need a little help on my program that is pasted below... Problem is that i get the following errors... Errors are marked in the program
--------------------Configuration: bcc5.5 - CUI Debug, Builder Type: Borland C++ Compiler--------------------
Compiling \Paul\C++ Programs\Studentfull.cpp...
Borland C++ 5.5.1 for Win32 Copyright (c) 1993, 2000 Borland
[Error] \Paul\C++ Programs\Studentfull.cpp:100: E2285 Could not find a match for 'stricmp(char,char *)' in function search()
[Error] \Paul\C++ Programs\Studentfull.cpp:178: E2285 Could not find a match for 'stricmp(char,char *)' in function del()
Sorry if my program is really stupid...
class student
{
int rollno;
char name[20];
char grade;
float marks;
public:
void getdata(void)
{
char ch;
cout<<"\nEnter roll number ";
cin>>rollno;
cout<<"\nEnter name ";
gets(name);
cout<<"\nEnter grade ";
cin>>grade;
cout<<"\nEnter marks ";
cin>>marks;
}
void putdata(void)
{
cout<<"\nRoll number: "<<rollno;
cout<<"\nName: ";
puts(name);
cout<<"\nGrade: "<<grade;
cout<<"\nMarks: "<<marks;
}
char getname(void)
{
return(name);
}
int getrollno(void)
{
return(rollno);
}
}s1;
void create()
{
ofstream fout;
fout.open("stud.dat",ios::out|ios::binary);
if(!fout)
{
cout<<"\nFile cannot be opened";
exit(1);
}
cout<<"\nEnter the details";
char ans='y';
while(ans=='y'||ans=='Y')
{
s1.getdata();
fout.write((char*)&s1,sizeof(s1));
cout<<"\nDo you want to continue ";
cin>>ans;
}
fout.close();
}
void append()
{
ofstream fout;
fout.open("stud.dat",ios::app|ios::binary);
if(!fout)
{
cout<<"\nFile cannot be opened";
exit(1);
}
cout<<"\nEnter more records to the file ";
char ans='y';
while(ans=='y'||ans=='Y')
s1.getdata();
fout.write((char*)&s1,sizeof(s1));
cout<<"\nDo you want to continue ";
cin>>ans;
fout.close();
}
void search()
{
char sname[20],found='n';
cout<<"\nEnter the name to be searched ";
gets(sname);
ifstream fin;
if(!fin)
{
cout<<"\nFile cannot be opened";
exit(1);
}
fin.read((char)&s1,sizeof(s1));
while(fin)
{
if(strcmpi(s1.getname(),sname)==0)//first error
{
s1.putdata();
found='y';
}
fin.read((char)&s1,sizeof(s1));
}
fin.close();
if(found=='n')
cout<<"\nRecord not found ";
}
void modify()
{
int rno;
long pos;
char found='n';
fstream finout;
finout.open("stud.dat",ios::in|ios::binary);
if(!finout)
{
cout<<"\nFile cannot be opened";
exit(1);
}
cout<<"\nEnter the roll number of the student whose record is to be modified ";
cin>>rno;
pos=finout.tellg();
finout.read((char)&s1,sizeof(s1));
while(finout)
{
if(s1.getrollno()==rno)
{
cout<<"\nThe details of the record of the student to be modified are: ";
s1.putdata();
finout.seekp(pos,ios::beg);
finout.write((char)&s1,sizeof(s1));
found='y';
break;
}
pos=finout.tellg();
finout.read((char*)&s1,sizeof(s1));
}
if(found=='n')
cout<<"\nRecord not found";
finout.close();
}
void display()
{
ifstream fin;
fin.open("stud.dat",ios::in|ios::binary);
cout<<"\nThe contents of the file are: ";
fin.read((char)&s1,sizeof(s1));
while(fin)
{
s1.putdata();
fin.read((char)&s1,sizeof(s1));
}
fin.close();
}
void del()
{
char rname[20];
char found='n';
ofstream fout;
fout.open("temp.dat",ios::out|ios::binary);
ifstream fin;
fin.open("stud.dat",ios::in|ios::binary);
if(!fin)
{
cout<<"\nFile cannot be opened";
exit(1);
}
cout<<"\nEnter the name of the student whose record is to be deleted: ";
gets(rname);
fin.read((char)&s1,sizeof(s1));
while(fin)
{
if(strcmpi(s1.getname(),rname)==0)//second error
{
cout<<"\nThe details of the deleted record is:\n";
s1.putdata();
found='y';
}
else
fout.write((char)&s1,sizeof(s1));
fin.read((char*)&s1,sizeof(s1));
}
fout.close();
fin.close();
if(found=='n')
cout<<"\nRecord not found";
remove("stud.dat");
rename("temp.dat","stud.dat");
}
int menu()
{
int choice;
cout<<"\n\tMENU";
cout<<"\n1)Create a class record";
cout<<"\n2)Display the class record";
cout<<"\n3)Append new record to the class record";
cout<<"\n4)Search for a record";
cout<<"\n5)Modify a record in the class";
cout<<"\n6)Delete a record from the class record\n";
cout<<"\nEnter your choice: ";
cin>>choice;
return(choice);
}
void main()
{
char ch='y';
while(ch=='y'|ch=='Y')
{
int j;
j=menu();
switch(j)
{
case 1:create();
break;
case 2:display();
break;
case 3:append();
break;
case 4:search();
break;
case 5:modify();
break;
case 6:del();
break;
default:cout<<"\nWrong menu number";
}
cout<<"\nDo you want to continue?(y/n) ";
cin>>ch;
}
exit(1);
}
Thanks in advance...
It looks like you're new here. If you want to get involved, click one of these buttons!
Comments
A few things, since this is cpp, you might consider using cpp functions in place of c versions... puts(), gets(), etc.
[code]cin.getline(char_array, sizeof char_array, deliminator);[/code]
The member function getname is prototyped so that it returns a single char.
[code]char *getname(void) { return name; }[/code]
It's hard to read the posted code, but it looks like your file functions would need to use the seek members to find the target record.