Thread: Password gate

  1. #1
    Registered User Queatrix's Avatar
    Join Date
    Apr 2005
    Posts
    1,342

    Exclamation Password gate

    How do you make a password gate in a windows program?

  2. #2
    Kiss the monkey. CodeMonkey's Avatar
    Join Date
    Sep 2001
    Posts
    937
    What's a password gate?
    "If you tell the truth, you don't have to remember anything"
    -Mark Twain

  3. #3
    Registered User r1ck0r's Avatar
    Join Date
    Apr 2005
    Location
    UK
    Posts
    30
    I'm just going to guess what you mean by 'password gate'..
    Here is some code I just threw together as an example of console password input. This code will most likely contain bugs, but it should give you the general idea.

    Code:
    #include <iostream>
    #include <conio.h>
    using namespace std;
    
    bool GetPassword(char * CorrectPass, int PassMaxLength)
    {
    	char * str = new char[PassMaxLength+1];
    	char chr;
    	int InputCounter = 0;
    	
    	do	{
    		chr = getch();
    		if(chr == (char)8)
    		{
    			if(InputCounter == 0) continue;
    
    			InputCounter--;
    			cout << (char)8 << " " << (char)8;
    		}
    		else if(chr != '\r')
    		{
    			str[InputCounter] = chr;
    			cout << "*";
    			InputCounter++;
    		}
    	}
    	while(InputCounter < PassMaxLength && chr != '\r');
    	str[InputCounter] = '\0';
    
    	if(strcmp(str,CorrectPass) == 0)
    	{delete[] str;  return true;}
    	
    	delete[] str;
    	
    	return false;
    }
    
    int main()
    {
    	cout << "Password: ";
    	if(GetPassword("password",100) == true)
    		cout << "\nCorrect Password!" << endl;
    	else
    		cout << "\nYou Suck!" << endl;
    	
    	return 0;
    }
    It's quite possible I missunderstood what 'password gate' meant, if I did, just ignore this whole post

  4. #4
    Registered User Queatrix's Avatar
    Join Date
    Apr 2005
    Posts
    1,342
    r1ck0r has the right idea, but it's not windows, it's DOS.

    Below is an example of a password gate.

  5. #5
    Registered User r1ck0r's Avatar
    Join Date
    Apr 2005
    Location
    UK
    Posts
    30
    There is a 'Windows Programming' section on this forum, this question would've been more suited there. Anyway, this link: http://www.winprog.net/ will give you an introduction into windows programming.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Problem reading a password from a file.
    By medeshago in forum C Programming
    Replies: 15
    Last Post: 12-21-2008, 07:20 AM
  2. logical operation functions in c; And, Or, Xor, Not etc..
    By Jasonx521 in forum C Programming
    Replies: 6
    Last Post: 10-03-2006, 12:24 AM
  3. [Q]Hide Password
    By Yuri in forum C++ Programming
    Replies: 14
    Last Post: 03-02-2006, 03:42 AM
  4. written command line password generator
    By lepricaun in forum C Programming
    Replies: 15
    Last Post: 08-17-2004, 08:42 PM
  5. password
    By hammers6 in forum C Programming
    Replies: 1
    Last Post: 10-10-2001, 12:14 AM