// Zeinalipour-Yazti Demetrios // csyiazti // cs10xx - // Lab Sec#24 // lab5 /* * This program reads in characters until the user enters the correct two-character sequence as a password. * The password is "cs". This password is used to open a door, let the user know when the door is open. * The program simply keep reading characters until the proper password has been entered. * The program will just wait for the user to type in more characters if the password has not been * entered correctly yet. If the password was entered correctly, it will output a statement saying * "the door has been opened" and then the program will be finished. * */ #include void main() { /* The idea is to have 2 variables * input_prev = the previous character * input = the current character */ char input_prev, input; cout << "Give me the password : "; while (true) { cin >> input; if ((input_prev=='c') && (input=='s')) { cout << "The door has been opened !\n"; break; } // keeping the current character as the previous character input_prev = input; } }