www.flickr.com

Convert Password input into Asterisk in C, C++

Saturday, November 12, 2011 Posted by Glenn Von Posadas

Here is my source code about converting the inputted password into asterisk * in C and C++




#include "iostream.h"
#include "conio.h"
#include "cstring.h" // for strcmp

using namespace std;
int main(void)
{
int c;
int i;
char pw[80];
start:

printf("\n1Enter Password:");

for ( i = 0; i < 79 && (c = getch()) != '\r'; ++i ) {
pw[i] = c;
putch('*');
}

pw[i] = '\0';


if ( strcmp(pw, "CORRECT") == 0 ) {
printf("\nPASSWORD CORRECT");
} else {
goto start;
}
getch();

return 0;
}

glenn von

Author: Glenn Posadas

20 year old 5th year Computer Engineering Student, a blogger, photographer, programmer, and an electronics hobbyist; a Christian who loves God very much..

Sharing is so Easy:
StumpleUpon DiggIt! Del.icio.us Blinklist Yahoo Furl Technorati Simpy Spurl Reddit Google Twitter FaceBook

Post a Comment

Drop a comment. Thank you guys!