Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<fstream.h>
- #include<iomanip.h>
- #include<conio.h>
- #include<windows.h>
- #include<string.h>
- int flag=0; char ch;
- struct password
- {
- char passs[25];
- };
- void enteringfirstpass()
- {
- password ok;
- cout<<"Enter your ___ pass\n";
- gets(ok.passs);
- ofstream fio("password",ios::out,ios::binary);
- fio.write((char*)&ok,sizeof(password));
- fio.close();
- }
- class question
- {
- public:
- char ques[1000];
- char option1[50],option2[50],option3[50],option4[50];
- int k;
- int qno;
- };
- void addquestion(void)
- {
- question abc;
- cout<<"Enter question number\n";
- cin>>abc.qno;
- cout<<abc.qno;
- ofstream fout;
- fout.open("question.txt",ios::out|ios::binary);
- cout<<"Enter Question!\n";
- gets(abc.ques);
- cout<<"Enter Options!\n";
- gets(abc.option1);gets(abc.option2);gets(abc.option3);gets(abc.option4);
- cout<<"Enter correct option number\n";
- cin>>abc.k;
- cout<<"dadalaa";
- fout.write((char*)&abc,sizeof(abc));
- fout.close();
- getch();
- }
- void dispsetting()
- {
- char chkpass[30];int count=0;
- password pass;
- cout<<"Enter your password\n";
- gets(chkpass);
- ifstream fi("password.txt",ios::in|ios::binary);
- fi.read((char*)&pass,sizeof(password));
- if(strcmpi(chkpass,pass.passs)==0)
- {
- cout<<" _|_|_| _|_|_|_| _|_|_|_|_| _|_|_|_|_| _|_|_| _| _| _|_|_|"<<endl;
- cout<<"_| _| _| _| _| _|_| _| _| "<<endl;
- cout<<" _|_| _|_|_| _| _| _| _| _| _| _| _|_|"<<endl;
- cout<<" _| _| _| _| _| _| _|_| _| _|"<<endl;
- cout<<"_|_|_| _|_|_|_| _| _| _|_|_| _| _| _|_|_|"<<endl;
- cout<<"\n\n\n";
- cout<<"1. ADD QUESTION\n" ;
- cout<<"2. DELETE QUESTION\n";
- cout<<"3. MODIFY QUESTION\n";
- cout<<"4. CHANGE PASSWORD\n";
- }
- else
- {
- cout<<"ACCESS DENIED!!!Wrong Password\n";
- while(strcmpi(chkpass,pass.passs)!=0)
- {
- cout<<"Please enter your passsword again\n";
- gets(chkpass);
- count++;
- if(count==4)
- {
- cout<<"You have entered wrong password 5 times\n Program will now terminate!!\n";
- exit(0);
- }
- }
- }
- }
- void pass()
- { password pass;
- char password[25];
- cout<<"Change Password Menu \n";
- cout<<"Do you want to change your password(y/n)\n";
- char ch1;
- cin>>ch1;
- if(ch1=='y'||ch1=='Y')
- {
- cout<<"Enter Old Password";
- gets(password);
- ifstream fi("password",ios::in|ios::binary);
- fi.read((char*)& pass,sizeof(password));
- fi.close();
- if((strcmpi(password,pass.passs)==0))
- { ofstream fo("password",ios::out|ios::binary);
- fo.write((char*)password,sizeof(password));
- fo.close();
- }
- }
- }
- void main()
- {
- enteringfirstpass();
- addquestion();
- pass();
- dispsetting();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement