how to only accept certain input?

okay so im supposed to make the user only enter a certain input that i want.
is it possible to do so using cin? if so how?

Thank you!
Could you be more specific? Give some examples?
The value of userID should be the last 6 digits of your ID (e.g. 112345). The user has to enter that specific number. if he doesn't, he will have 3 chances to enter it right.. if the 3 chances are done, the program will exit. if he enters it right.. user will move on to other stuff in the program.

let me know if it's clear enough. if not please ask so i can make it clearer.

Thank you very much
You can ask for input in a loop and count the number of times they give an incorrect value:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
int input = 0;
int fails = 0;
while((std::cout << "Enter the ID: ") && (std::cin >> input))
{
    if(input == 112345)
    {
        std::cout << "Correct!" << std::endl;
        break;
    }
    else if(fails < 3)
    {
        std::cout << "Try again" << std::endl;
        ++fails;
    }
    else
    {
        return 0; //assuming this code is in the main function
    }
}
got it!!! would i do the same thing.. if lets say... it asks for the userID and Password... for example the userID is 112345 and the password is: 9292.. would it be the same steps?
Yes. If you find yourself needing to copy, paste, and edit code, then you should probably make a function out of it, but I'll leave that to you.
do i have to use the while for the loop? can i use " for " instead?
for and while are interchangeable in almost all cases - the reason we have both is because they are better suited to different cases.
Topic archived. No new replies allowed.