HELP ME!!

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
void Log_In()
{
	system("cls");
	
	  gotoxy(30, 30);
	  time_t now;
      time(&now);

      printf("\t\t\t\t\t\tToday is %s",ctime(&now));
     cout<<endl;
	cout << "\t\t\t\t\t\t\t\t\t\tLOG IN" << endl;
	cout<<endl;
	cout << "\t\t\t\t\t\t\t\t\t\tUsername: ";
	cin >> acct.userLog;
	cout << "\t\t\t\t\t\t\t\t\t\tPassword: ";
	cin >> acct.passLog;

			cout << "*";   //printf("*");
			i++;	 }	 		
	if (strcmp(acct.userLog, acct.userReg)==0 && strcmp(acct.passLog, acct.passReg)==0)
	{
		cout << "\t\t\t\t\t\t\t\t\t\tAccess Granted!";
		Sleep(1000);
		system("cls");
		
	}
	else
	{
		cout << "\t\t\t\t\t\t\t\t\t\tAccess Denied! Please try again.";
		Sleep(100);
		system("cls");
			int x;
	int y;
	
	{
		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");
		 system("color 3b");
account_Options();
	}
}
}

could please someone help me to make the password field like this "*******"
you want an asterisk to be displayed instead of whatever you are typing? if that is the case...

std::string password = "";
char char1 = ' ';

while (char1 != 27) // 27 is the ascii code for ESCAPE
{ // 13 is for ENTER if that's what you need
char1 = getch();
password += char1;
std::cout << "*" ;
}

the loop will run until you press ESC.
your password goes to the password variable, obviously. (and remember to include the conio.h header in order to use getch).
however, this will add any pressed keys to your password variable. for example, in the code above you will see that the password variable actually contains the ESC ascii symbol at the end, so you'll have to check or remove any unwanted key pressess, but that shouldn't be hard
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
void Log_In()
{
	system("cls");
	
	  gotoxy(30, 30);
	  time_t now;
      time(&now);


};
std:: string password = acct.passLog;
char char1 = ' ';

while (char1 != 27) // 27 is the ascii code for ESCAPE
{ // 13 is for ENTER if that's what you need
char1 = getch();
acct.passLog += char1;
std::cout << "*" ;
      printf("\t\t\t\t\t\tToday is %s",ctime(&now));
     cout<<endl;
	cout << "\t\t\t\t\t\t\t\t\t\tLOG IN" << endl;
	cout<<endl;
	cout << "\t\t\t\t\t\t\t\t\t\tUsername: ";
	cin >> acct.userLog;
	cout << "\t\t\t\t\t\t\t\t\t\tPassword: ";
	cin >> acct.passLog;
	if (strcmp(acct.userLog, acct.userReg)==0 && strcmp(acct.passLog, acct.passReg)==0)
	{
		cout << "\t\t\t\t\t\t\t\t\t\tAccess Granted!";
		Sleep(1000);
		system("cls");
		
	}
	else
	{
		cout << "\t\t\t\t\t\t\t\t\t\tAccess Denied! Please try again.";
		Sleep(100);
		system("cls");
			int x;
	int y;
	
	{
		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");
		 system("color 3b");
account_Options();
	}
}




Please help me to fix this cause i have a lot of things to do like Mathematics.... Thanks for your cooperation
@ shuraman the code that you posted is for the string function only
stop double posting and read the link i put in your other post.
http://www.cplusplus.com/forum/general/141667/
Topic archived. No new replies allowed.