#include <conio.h>

#include<iostream>

#include<string.h>

#include<fstream>

using namespace std;

int main(){

char username[15], password[7];

int limit=0;

ifstream fin("login.txt");

int correct=0;//use as a flag

while(limit<3){

      cout<<"\nPlease Enter your name: "<<endl;

      cin>>username;

      cout<<"\nPlease Enter your password (6 char) :"<<endl;

     for(int i=0;i<6;i++){password[i] = getch(); cout<<'*';cout.flush();}//FOR

             password[i]='\0';//last character to 0

    char u[15], p[7]; //read from the login.txt

    while(fin >> u >> p){

            if(strcmp(username,u)==0 && strcmp(password,p)==0){

                      cout<<"\nYour Password is ACCEPTED"<<endl;

                      correct=1;

                      return 1;

                }//IF

               } //while

          if(correct==0){cout<<"\nYour Password is incorrect. Please try again."<<endl;

          limit++;}//IF

          }//WHILE

      cout<<"\nSorry, you've used all your chances."<<endl;

      return 0;

   }//MAIN

Hosted by www.Geocities.ws

1