Convert Password input into Asterisk in C, C++
Saturday, November 12, 2011
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;
}
Sharing is so Easy: |
Labels:
C Programming,
C++,
sample programs