if statement problem

Hello, I have recently started C++ and just made this program to test if statements to create a numerical password. However, it only gives me the "wrong password" option, even if it's correct. Any suggestions?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
cin >> pass;
    if (pass == 0336)
     {
      cout << "\nPassword match!\n";
      system ("PAUSE");
     }
    else if (pass != 0336)
     {
       if (attempts >= 2)
        {
         attempts = attempts - 1;
         cout << "\nIncorrect password. " << attempts << " attempts remaining.\n";
         goto top;
        }
       else if (attempts == 1)
        {
         cout << "\nAuthentication failed!\n";
         system ("PAUSE");
         return 0;
        }
     }
If your numbers start with a zero, they are treated as octal (base 8) not decimal (base 10)

So 0336 is really 336 octal... which equals 222 decimal.


Long story short: don't put 0 at the start of your numbers.
Topic archived. No new replies allowed.