Coding Forums

Web development and Application development forums. Seek solution from Experts at Coding-Forum. An Ad-Revenue sharing forum.
Welcome Guest Search | Active Topics | Members | Log In | Register

Coding Forum » Application Development Forums » C/C++ Programming » Password code - help needed please
Password code - help needed please Options
R3_TBH
Posted: Saturday, April 18, 2009 11:54:11 AM
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;
}
Sponsor
Posted: Saturday, April 18, 2009 11:54:11 AM
Users browsing this topic
Guest

Coding Forum » Application Development Forums » C/C++ Programming » Password code - help needed please

Forum Jump
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.

Main Forum RSS : RSS

This page was generated in 0.022 seconds.

Powered by YAF. Theme is derived from Dating forums.
Copyright 2008 Coding Forum