Limit Login Attempt without return 0!

Hello everyone, i am totally new to C++. I use DevC++ for my project but i am stuck in one case. I found a lot of examples to limit login attempt. Here i write it into a int main function but i want code to stop after 3 falied attempts, and i want code to keep running, not return to zero in case of succesfull login, please anyone 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
  int main(){
	
	
system("cls"); ///clear the console window


string username;
string password;
int attempts = 0;


for (int attempts = 0; attempts < 3; attempts++ )
{
    cout << "Enter your username: " << endl;
    cin >> username;
    cout << "Enter your password: " << endl;
    cin >> password;

    if ( username == "billy" && password == "bob" )
    {
      	cout << "Access granted" << "\n" <<endl;
	
break;
    }

    else
    {
    cout << "Incorrect username/password combination. Please try again." << "\n" <<endl;
    
	}

    cout << "Maximum attempts reached." << endl;  
}

 return 0;




    FILE *fp, *ft; /// file pointers
    char another, choice;
 
    /** structure that represent a employee */
    
    struct emp{
        char name[40]; ///name of employee
        char gender[40];
        char email[40];
        
        int studentnumber;
        int phonenumber;
		int age; /// age of employee
		
		char course[40];
        int grade;
	};
.
.
.

The last part is just a little part of program.
Last edited on
Your return 0 is in the wrong place.

Move line 35 to after line 32.
most new compilers don't even need return 0; statement these days .Clang is one of them .
That doesn't change the fact the OP has the return in wrong location.
Topic archived. No new replies allowed.