project of password in c++ with file handling
#include<bits\stdc++.h> // This Heider file can be ude instead of all oher heiderfiles
#include<fstream>
using namespace std;
void code_function (){
int count = 4 ;
string pass_store;
ofstream password;
cout<<"Set a new password :"<<endl;
password.open("D:\\Password.txt " , ios :: app ); // this is location of your file , and ios :: app will remain the after it excuate mant times
getline(cin,pass_store);
password<<endl<<pass_store;
string pass_comp ;
do {
ifstream password;
password>>pass_store;
cout<<"Enter Password :";
getline(cin,pass_comp);
if ( pass_store == pass_comp ){
cout<<"Password Entered Successfull "<<endl;
break;
}
else if (pass_store != pass_comp){
cout<<"Wrong Password "<<endl;
count -=1;
cout<<count <<" tries remaning"<<endl;
}
else
cout<<"invalid Input!"<<endl;
} while (count != 0);
}
int main(){
code_function();
return 0;
}
// By Muhammad Najaf Shafee from D G khan