Advertisement
Guest User

TurboC Password

a guest
Apr 2nd, 2013
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.56 KB | None | 0 0
  1. #include<conio.h>
  2. #include<string.h>
  3. #include<iostream.h>
  4.  
  5. void main(){
  6.     highvideo(); // Makes color's sexy as hell
  7.     clrscr();    // You know it
  8.     int pass_not_entered = 1;   // Checks if password is entered or not
  9.     char password[100];  // Stores the  password temporarily
  10.     int len = 0; // Current length of password
  11.     cout<<" Username : coolgirl \n Password : ";  // Print this once
  12.     while( pass_not_entered == 1 ){
  13.         char ch = getch();    // Gets the character
  14.         if( ch == 13){        // Gets us out of here if its ENTER
  15.         // ENTER is always 13
  16.             password[len] = '\0';  // This tells it where to stop in the string
  17.             pass_not_entered = 0;  // Makes sure we break out of the loop
  18.         }else if( ch == 8 ){   // Dunno if its backspace on your computer but for me it was backspace
  19.         // Pretty much moves our pointer in the "string" back so that we can rewrite it :P
  20.             len --;
  21.         }else{
  22.             // Enters the character to the
  23.             // current place in string
  24.             password[len] = ch;
  25.             len++;  // Increments the current pointer
  26.             // This could be in one line ...
  27.             // As password[len++] = ch;
  28.         }
  29.         clrscr(); // CLears the screen
  30.         // Prints our pretty looking gui
  31.         cout<<" Username : coolgirl \n Password : ";
  32.         // Prints the appropiate number of stars
  33.         for( int j = 0; j < len ; j++){
  34.             cout<<"*";
  35.         }
  36.     }
  37.     cout<<endl<<endl<<endl;
  38.  
  39.     // checks if u entered the right password
  40.     if( strcmp("suja",password) == 0 ){
  41.         cout<<"Right Password FRIEND";
  42.         // Says yes you are right
  43.     }else{
  44.         cout<<"Wrong password BITCH";
  45.         // Says no you are wrong
  46.     }
  47.     getch();
  48. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement