#include<iostream>
#include<fstream>
#include<conio.h>
#include<string>
using namespace std;
class user
{
public:
int pswrd,age;
string inuser;
string inpass;
string userr;
string pass;
string username,name,fname,adress;
void password() //this function will save userpassowords
//registering the user
{
ofstream pass("pasword.txt",ios::binary|ios::out|ios::app);
pass<<"\n"<<pswrd;
pass.close();
}
void user_name()
{
ofstream user("usernamee.txt",ios::binary|ios::out|ios::app);
user<<username<<endl;
user.close();
}
void profile()
{
ofstream prof("userprofile.txt",ios::binary|ios::out|ios::app);
prof<<name<<"\t"<<fname<<"\t"<<age<<"\t"<<adress<<"\n\n";
prof.close();
}
void login()
{
ifstream Passfile("password.txt", ios::in);
Passfile>>inpass;
ifstream Userfile("username.txt", ios::in);
Userfile>>inuser;
cout<<"USERNAME: ";
cin>>userr;
cout<<"PASSWORD: ";
cin>>pass;
Userfile.close();
Passfile.close();
if(userr==inuser&&pass==inpass)
cout<<"\naccess granted";
else
cout<<"wrong password";
getch();
}
};
void main()
{
user user1;
char ch;
cout<<"(1)login\n\n(2)register\n";
cin>>ch;
switch(ch)
{
case '2':
cout<<"enter your username:";
cin>>user1.username;
user1.user_name();
cout<<"\nenter your password:";
cin>>user1.pswrd;
user1.password();
cout<<"\nenter your name:";
cin>>user1.name;
cout<<"\nenter your father name:";
cin>>user1.fname;
cout<<"\ncout enter your age :";
cin>>user1.age;
cout<<"\nenter your adress:";
cin>>user1.adress;
user1.profile();
cout<<"\n\n registration was successfull ";
break;
case '1':
user1.login();
break;
getch();
}
}
please help any body
This post has been edited by Salem_c: 07 October 2012 - 12:26 AM
Reason for edit:: added [code][/code] tags - learn to use them yourself

New Topic/Question
Reply



MultiQuote




|