program errors... help

struct userdetails{
char username[100];
char password[100];
char name[100];
char dob[20];
}user1;

int login();
int login(){

char user[100],check;
char pass[100];
int k=0;
clrscr();
display("Select\n1.Login\n2.Exit\n");
int n;
cin >> n;
if(n==1)
{
display("Enter user name: "); //asking for user name
gets(user);
ifstream fin("userRecords.dat",ios::in|ios::binary);
while(fin.read((char*)&user1,sizeof(userdetails))){
if(!strcmp(user1.username,user)){
clrscr();
fast_display("Name: "); fast_display(user1.name);
fast_display("\nUserName: "); fast_display(user1.username);
fast_display("\nDate of Birth: "); fast_display(user1.dob);
display("\nIs this user you?(y/n)");
cin>> check;
if(check=='y'||check=='Y'){
display("Enter password: ");
gets(pass);
if(!strcmp(pass,user1.password)){
display("Access granted\n");
getch();
k=1;
}
else{
display("Wrong password");
}
}
fin.close();
}//if()
}//while(fin.read)
}
else if(n==2){
exit(1);
}
else{
cout << "Invalid option";
}

return k;
}//void login()

int registeration(){
char acc[100],ik; int k=0; char already;
display("Enter the accessing password: ");
gets(acc);
if(!strcmpi(acc,"abhishek")){
k=1;
display("Access granted\n PLease make your profile\n Press Enter to continue");
getch();
char n[100],un[100],pass[100],d[20];
clrscr();
fast_display("Enter your name: ");
gets(n);
already = exist(n,1);
if(already!='y'&&already!='Y'){

clrscr();
cout << "Enter your name: "; puts(n);
display("\nEnter your UserName: "); gets(un);
already=exist(un,2);
if(already!='y'&&already!='Y'){
clrscr();
cout << "Enter your name: "; puts(n);
cout<<"\nEnter your UserName: "; puts(un);
display("Enter DateOfBirth: "); gets(d);
display("\nEnter Password: "); gets(pass);
enter_data(n,un,d,pass);
}
else{k=login;}
}
else{k=login();}
}
return k;
}//int reg
char exist(char [], int);
char exist(char a[],int n){ char ans='k';
`ifstream fin("userRecords.dat",ios::in|ios::binary);
while(fin.read((char*)&user1,sizeof(userdetails))){
switch(1){
case 1: if(!strcmp(user1.name,a)){clrscr(); display("User with same name exits\n");fast_display("Name: "); fast_display(user1.name); fast_display("\nUserName: "); fast_display(user1.username);fast_display("\nDate of Birth: "); fast_display(user1.dob); display("\nPress(y) if you want to go to login and ()n to continue...");cin >> ans;}
break;
case 2: if(!strcmp(user1.username,a)){clrscr(); display("User with same UserName exits\n");fast_display("Name: "); fast_display(user1.name); fast_display("\nUserName: "); fast_display(user1.username);fast_display("\nDate of Birth: "); fast_display(user1.dob); display("\nPress(y) if you want to go to login and ()n to continue...");cin >> ans;}
break;
}
if(ans!='k'){break;}
}
return(k);
}

void enter_data(char [], char[],char[],char[]);
void enter_data(char n[],char un[], char d[], char pass[]){
ifstream check("userRecords.dat",ios::in|ios::binary);
if(!check){
ofstream fout("userRecords.dat",ios::out|ios::binary);
strcpy(user1.username,un);
strcpy(user1.password,pass);
strcpy(user1.name,n);
strcpy(user1.dob,d);
fout.write((char*)&user1,sizeof(userdetails));
}
else{
ofstream fout("userRecords.dat",ios::app|ios::binary);
strcpy(user1.username,un);
strcpy(user1.password,pass);
strcpy(user1.name,n);
strcpy(user1.dob,d);
fout.write((char*)&user1,sizeof(userdetails));
}
}
/*
There are 5 errors
1. Call to undefined function exist
2. Call to undefined function enter_data
3. Cannot convert 'int(*)()'to'int'
4. Illegal character
*/
Please edit your code and use code tags, it's unreadable at the moment - http://www.cplusplus.com/articles/jEywvCM9/
Also, when listing the errors, withholding the complete error message and line numbers is rarely a helpful choice of action.
Topic archived. No new replies allowed.