Guys Help

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
#include<iostream>
#include<windows.h>
#include<string>
#include<iomanip>
#include <conio.h>
#include<stdlib.h>
using namespace std;
int main () 
{
	char username[5]="try"; 
	char password[7]="quest"; 
	char uname[10];
	char pass[10];
	
	
	bool account=false;
	int cnt=0;
	while(1){ 
		system("cls"); 
		cout<<endl;
			cout<<endl;
				cout<<endl;
					cout<<endl;
						cout<<endl;
							cout<<endl;
								cout<<endl;
									cout<<endl;
										cout<<endl;
											cout<<endl;
												cout<<endl;
													cout<<endl;
														cout<<endl;
															cout<<endl;
															cout<<endl;
															cout<<endl;
															cout<<endl;
															cout<<endl;
															cout<<endl;
															cout<<endl;
															cout<<endl;
															cout<<endl;
															cout<<endl;
															cout<<endl;
															cout<<endl;
															cout<<endl;
															cout<<endl;
															cout<<endl;
															cout<<endl;
															cout<<endl;
															cout<<endl;
															cout<<endl;
															cout<<endl;
															system("color 3a");
		
		 char ch[5];
 char mypass[8]="try";
 char username[8]="quest";
 int y=0;
 char upass[5];{
  cout<< "\t\t\t\t\t\t\t\t\t\tEnter Username:";
 cin>>username;
  cout<<endl;
   cout<<endl;
 cout<<"\t\t\t\t\t\t\t\t\t\tEnter PASSWORD: ";
 cin>>mypass;
cout<<endl;}

	do{

	ch[y]=_getch();

	if(ch[y]=='\x0D' || y==4) //enter is the 13 scan code
	{
	 upass[y]='\0'; //null char, end of your upass string
	 break;
	}
	if(ch[y]=='\x08' && y!=0) //scancode 8 is backspace
	{
	 y--;
	 cout<<"\b \b";
	}
	else
	{
	 upass[y]=ch[y]; //assign the value 'ch' as your password
	 cout<<"*";
	 y++; // Increase AFTER assigning
	}	int i=0;
		while(1)
		   { 
			pass[i]=getch(); 
			if(pass[i]==13)  
			{
				pass[i]='\0';
				break;
			}
			cout << "*";
			i++;	 		
		}	
		
		if(!strcmp(uname,username) && !strcmp(pass,password)) { 
			account=true;
			break;
		} 
		
		else     
		
		{
			cnt++;
			if(cnt==2) 
			   break;
			cout << "\nIncorrect username or password\n";
			cout << "No of try: "<<cnt <<endl;
			
			system("pause");

		}
	}
	while(1);
	if(account)	{
		cout << "\n\n\t\t\t\t\t\t\t\t\t\tAccess Granted";
		Sleep(2000);
		system("cls");
		Sleep(2000);
		goto welcome;
	} else
	{
	 
	system("cls");
	{
	int x;
	int y;
	while (y>=1)
	{
		system("color 4c");
		 cout<<"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n";
		 for (x=3;x>=1;x--)
		 {
		 	cout<<"\n\n\n\n\t\t\t\t\t\t\t\t\t\tWARNING!! Intruder Alert!!\n\n\n";
		 	Beep(3000,2000);
		 }
		 system("cls");
	}
}
     
    


Guys please help me i Set a password and a username and when i the correct username and password yet still denied please help me
Last edited on
This is clearly not the code you're using since it doesn't compile. Where, for instance, is the labeled referred to on line 124?

No value is ever assigned to any element of uname so it seems likely that the comparison on line 100 will never work out the way you expect.
what should i do?
Topic archived. No new replies allowed.