Page 460 - C++
P. 460

}
                 word[j]='\0';
                 cout<<"\n\n Confirm the new password:\n\n";
                 for(j=0;;j++)
                    {pass[j]=getch();
                     if(pass[j]=='\b')
                       {j-=2;
                        cout<<"\b \b";}
                     else if(pass[j]=='\r')
                            break;
                     else
                        {if(j==25)
                            {j--;
                             cout<<"\b*";}
                          else
                              cout<<"*";}
                              }
                   pass[j]='\0';
                   if(strcmp(pass,word)!=0)
                      {cout<<"\n\n\a\t\tPassword not confirmed! Try again";
                       getch();}
                    }while(strcmp(pass,word)!=0);
                 cout<<"\n\n\t\t Password changed successfully!";
                 getch();
                }

                       //Function to be operated by manager
                void item::manager()
                {char pass[26];
                 int j;
                 clrscr();
                    for(int i=3;i>0&&strcmp(pass,word)!=0;i--)
                       {clrscr();
                        cout<<"\n\t\t\t Login!\n\n Enter password (You have "<<i<<"
                chances):\n\n";
                        for(j=0;;j++)
                            {pass[j]=getch();
                             if(pass[j]=='\b')
                               {j-=2;
                                cout<<"\b \b";}
                             else if(pass[j]=='\r')
                                    break;
                             else
                                {if(j==25)
                                    {j--;
                                     cout<<"\b*";}
                                else
                                    cout<<"*";}
                              }
                        pass[j]='\0';
                        if(strcmp(pass,word)!=0)
                           {cout<<"\n\n\t\t\aInvalid password!";
                           getch();}
                        }
   455   456   457   458   459   460   461   462   463   464   465