Advertisement
huutho_96

password

Mar 11th, 2015
344
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.79 KB | None | 0 0
  1. #include <iostream>
  2. #include <Windows.h>
  3. #include <conio.h>
  4. using namespace std;
  5. void gotoxy(int column, int line)
  6. {
  7. COORD coord;
  8. coord.X = column;
  9. coord.Y = line;
  10. SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE), coord );
  11. }
  12. void loginmenu()
  13. {
  14. system("cls");
  15. gotoxy(30, 13); cout << "password: ";
  16. }
  17. void main()
  18. {
  19. int a;
  20. int dem = 0, sokitu;
  21. char pass[15];
  22. do
  23. {
  24. sokitu = 0;
  25. loginmenu();
  26. do
  27. {
  28. a = _getch();
  29. cout << "*";
  30. pass[sokitu] = a;
  31. sokitu++;
  32. } while (a != 13 && sokitu < 14);
  33. pass[sokitu - 1] = '\0'; //do nhận ký tự enter ở vòng lặp nên phải đè ký tự kết thúc vào ví trí enter
  34. if (strcmp(pass, "admin") == 0)
  35. {
  36. cout << "thanh cong" << endl;
  37. break;
  38. }
  39. dem++;
  40. } while (dem < 3);
  41. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement