#include <conio.h>
#include <stdio.h>
#include <windows.h>
void display(void);
void menu(void);
int main()
{
char username[9];
int password=0,x=1;
display();
do
{
printf("\n\t\t\tPlease enter your username:");
scanf("%s",username);
printf("\n\n\t\t\tPlease enter your password:");
scanf("%d",&password);
//problem
if (username == 'udental' && password == 1987)
menu();
else
{
printf("\n\n\t\t\t YOU HAVE MADE AN INVALID INPUT");
printf("\n\n\t\t\t PLEASE TRY AGAIN\n\n");
Sleep (1000);
system("cls");
}
x++;
}while(x<4);
printf("\n\n\n\t\tSORRY BUT YOU HAVE ENTERED INCORRECT INFORMATION");
printf("\n\n\t\t\t GOODBYE");
getch();
return 0;
}
void display(void)
{
printf("\n\n\t\t\tSMILES DENTAL CENTRE\n\n");
printf("\n\n\t\t WHERE YOU GET THE PERFECT SMILE\n\n");
printf("\n\n\n\n\t\t PRESS ENTER TO CONTINUE");
getchar();
system("cls");
}
void menu(void)
{
printf("\n\n\t\tWELCOME TO THE SYSTEM MENU");
printf("\n\n\t\t PLEASE SELECT YOUR OPTION BELOW");
}
HBK_100
-7
Newbie Poster
Recommended Answers
Jump to PostI don't know what the problem is, but I see two glaring problems.
- scanf("%s", username); -- what happens if someone enters 20 characters as the user name? A: Program will most likely crash because username can only hold 8 characters. Solution: use fgets() instead of scanf() because fgets() will …
All 4 Replies
Ancient Dragon
5,243
Achieved Level 70
Team Colleague
Featured Poster
abhimanipal
91
Master Poster
xavier666
56
Junior Poster
jonsca
1,059
Quantitative Phrenologist
Team Colleague
Featured Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.