Aborting an else?

Basically so far my code doesnt abort if the password is incorrect, the count down timer does work however

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
#include <iostream>
#include <string>
#include <windows.h>
#include <cstdlib>
using namespace std;

int main() {
	int pass;
	cout << "Hello sean, what is your password?" << endl;
	cin >> pass;

if (pass == 123)  // bad to have a semi-colon on this line as well
{ // put enclosing braces in, even if if you one line under your if and else
    cout << "Access granted welcome sean" << endl;
	cout << "how old are you sean? " << endl;
	int iNumber;
	cin >> iNumber;
    cout << "Sean you're " << iNumber << "Years old" << endl;
}
else
{
    cout << "Access denied! Password is incorrect." << endl;
	Sleep(1000);
	cout << "Quiting in 5 seconds" << endl;
	Sleep(1000);
	cout << "4" << endl;
	Sleep(1000);
	cout << "3" << endl;
	Sleep(1000);
	cout << "2" << endl;
	Sleep(1000);
	cout << "1" << endl;
	Sleep(1000);
    return(0);
    abort();

}

	return 0;
}
abort is not called because the return statement on the line above ends the function.
Thank you peter
Topic archived. No new replies allowed.