Log in

View Full Version : Programming in C



Petit Ours
10-29-2012, 05:12 PM
Hello guys :D I have an homework for college and i dont understand how to do it :/

i need to create a program in C:

-The program have to ask to the user what is his user name and his password that he want to create.

- When the user will enter his password, * this character need to replace the letter and the program need to ask the password twice to be sure its right.

- If there is already a user and the good password have been enter, the user account can be replace by another one else it cannot.


This is only a small part of my work but i cant figure out how to create it :/

Please help me fast :D


DarkstaR
Syntax
Forgee

this is what i have done so far :/

#include <stdio.h>
#include <conio.h>
#include <ctype.h>


int main(void)
{
int mdp[15];
int user[10];
int choix,i;
char c;
do
{
printf("\nMENU\n");
printf("A) Créer compte\n");
printf("B) Créer combinaisons (max de 5)\n");
printf("C) Afficher combinaisons\n");
printf("D) Combinaison gagnante\n");
printf("E) Validation\n");
printf("F) Nouveau tirage\n");
printf("Q) Quitter\n");
choix=toupper(getch());
switch(choix)
{
case 'A':
printf("Choississez le nom de votre compte:");
scanf("%s",user);
printf("Choississez votre mot de passe:");
c = getch();
for(i=0;i<15;i++)
{
do
{
if(c<=33 && c<=126)
{
printf("*");
}
}while (c !=13);



}
}while(choix!='Q');
return 0;
}

DarkstaR
10-29-2012, 05:48 PM
1. Store password as hashes, compare the hashes.
2. Do something similar to SSH login where you just erase the character as soon as you get it so the password is totally invisible. A backspace + a print * would also do the stars if you're hellbent on them.
3. Hope their password doesn't contain a Q
4. What the hell is the 0-14 loop for? Just to print 14 stars no matter what? wut.

Petit Ours
10-29-2012, 06:18 PM
1: I need to ask what is the user name:

printf("What is your user name?");
scanf("%s",userName);

2: I need to ask the password and repeat it twice: I need to put the password into a table.

password[] = c

printf("What is your password?");


How can i compare the two password to make sure they match and how can i print the * instead of the character.

What happens if the user tried to erase his password? I tried to do it but when the user was typing enter or backspace there were still star on my screen.