Want input in password format

This is a discussion on Want input in password format within the C Programming forums, part of the General Programming Boards category; hi, actually i am working on a project, 99% of that is complete the only thing left is that i ...

  1. #1
    Registered User
    Join Date
    Oct 2007
    Posts
    3

    Want input in password format

    hi,

    actually i am working on a project, 99% of that is complete the only thing left is that i need that the password entered by the should be in ( *****) form.....

    sumone plz help me out of this prob.

  2. #2
    Deathray Engineer MacGyver's Avatar
    Join Date
    Mar 2007
    Posts
    3,211
    I wrote a Windows version before:

    Code:
    char *getPass(char *szBuffer, size_t len)
    {
    	size_t i;
    	HANDLE hIn = GetStdHandle(STD_INPUT_HANDLE);
    	HANDLE hOut = GetStdHandle(STD_OUTPUT_HANDLE);
    	DWORD dwOld, dwNumRead, dwNumWritten;
    	if((hIn != INVALID_HANDLE_VALUE) && (hOut != INVALID_HANDLE_VALUE))
    	{
    		if(GetConsoleMode(hIn,&dwOld))
    		{
    			if(SetConsoleMode(hIn,ENABLE_PROCESSED_INPUT))
    			{
    				for(i=0;i<len-1;i++)
    				{
    					if(ReadConsole(hIn,&szBuffer[i],1,&dwNumRead,NULL))
    					{
    						if(szBuffer[i] == '\r')
    						{
    							break;
    						}
    						else WriteConsole(hOut,"*",1,&dwNumWritten,NULL);
    					}
    					else break;
    				}
    				WriteConsole(hOut,"\n",1,&dwNumWritten,NULL);
    				szBuffer[i] = '\0';
    				SetConsoleMode(hIn,dwOld);
    				return szBuffer;
    			}
    		}
    	}
    	return NULL;
    }
    If you want a *nix version, I think someone else might posted one awhile ago in the C++ section, but I could be wrong on that. It might have been something else similar.

  3. #3
    Registered User
    Join Date
    Oct 2007
    Posts
    3

    thanks but....

    it is preety much complecated


    it will not be possible for me to implement it on my program......

  4. #4
    Deathray Engineer MacGyver's Avatar
    Join Date
    Mar 2007
    Posts
    3,211
    Then you have to specify what you want and why this won't work.... Give us details. Don't make us guess what you want.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Input a password and replace with *s
    By Abda92 in forum C Programming
    Replies: 45
    Last Post: 10-06-2007, 03:52 PM
  2. large program code ,please help
    By Ash1981 in forum C Programming
    Replies: 14
    Last Post: 01-30-2006, 05:16 AM
  3. Trouble with a lab
    By michael- in forum C Programming
    Replies: 18
    Last Post: 12-06-2005, 10:28 PM
  4. EOF messing up my input stream?
    By Decrypt in forum C++ Programming
    Replies: 4
    Last Post: 09-30-2005, 03:00 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21