Rank: Newbie Groups: Member
Joined: 2/3/2009 Posts: 3 Points: 9 Location: uk
|
Hi guys, i have a code which asks for a username and password. Im trying to make it so that when the user enters their password, instead of seing (in this example: cyclone) you would see: *******. So basicly im trying to make the password private. Any help would be good thanks. the code i have so far is below :)
#include <stdio.h> #include <string.h>
int main(){ int len; char user1[7], name[] = "Gerry"; char pass1[9], pass[] = "cyclone";
printf("PleaseEnterYourUsername: "); fgets(user1, 7, stdin); len = strlen(user1) - 1; if (user1[len] == '\n') user1[len] = '\0';
if (!strcmp(user1, name)) { printf("\n\nPlease enter your password: "); rewind(stdin); fgets(pass1, 9, stdin); len = strlen(pass1) - 1; if (pass1[len] == '\n') pass1[len] = '\0';
if (!strcmp(pass1, pass)) printf("\n\nCorrect Password"); else printf("\nIncorrect password"); }else printf("\nIncorrect username");
printf("\nPress return to exit\n"); rewind(stdin); getchar(); return 0; }
|