Hello,
Thanks for the replies.
Salem, thanks for the help. I can now not put in a 5 or more digit number, if I do, the loop will run and not stop giving chance to enter a new number. Also, if I enter a 4 digit number, then another 4 digit number that is the same, and check that the second number that the user enters is the same as the first number, it will say that they do not match, whereas it didnt when using 'int'. The same happens with 3, 2 or 1 digit numbers. Please could you see if anything is wrong within this code?
Code:
#include <iostream>
using namespace std;
int main ()
{
int loop;
do//set pin loops
{
char pin[5];
char pinconfirm[5];
loop = 1;
cout<< "Please set 4 digit pin code: ";//set pin
cin.getline ( pin, 5, '\n' ); //enter pin
cout<< "\n\nPlease confirm: ";//confirm pin
cin.getline ( pinconfirm, 5, '\n' );//enter confirmation
if (pin != pinconfirm)//check if passwords match
{
cout<< "\n\nPasswords do not match, please try again.\n\n\n";
}
else
{
loop = 0; //break loop of setting pin
}
} while ( loop != 0 );
}
twomers, thank you also, I get the basic idea how to acomplish this now. I tried to run the code you had, but the compiler gave an error with 'VK_RETURN' as it has not been declared as a variable. Am I supposed to replace this with something?
Help apreciated, thanks.
EDIT:
I have declared 'VK_RETURN' as an int variable, and it works fine, apart from when I press return, it just comes up with an additional star, any ideas? Thanks.