0

I need some code that checks the number of characters entered and if it is not seven it needs to display "Error not enough numbers"

i already tried (strlen(pin_code) == 7); but it says invalid conversion from int to const char...

It needs to not conflict with the checking of the pin number either...

int pin_num =1234567;
     do{
     cout << "Please enter your unique 7 digit pin code: ";
     cin >> pin_code;
     system("cls");
     }
     while(pin_code != pin_num);
          
     cout << "Code Accepted";
     Sleep(1000);
     system("cls");
     }

Thanks,
Adam

3
Contributors
5
Replies
6
Views
6 Years
Discussion Span
Last Post by VernonDozier
0

Why would you want to strlen() and integer? What is strlen() used for?

What is it that makes a 7 digit number different from, say, a 4 digit or 8 digit number?

But, if you are going to have a pin value ready for them to match, who cares if they enter 7 digits or not? If the pin doesn't match, it doesn't match.

0

Yeh thats what i thought, either way it still does the same thing, its just that its in the assignment that we have to tell the user if you havent entered in enough characters,

0

So my question stands:
What is it that makes a 7 digit number different from, say, a 4 digit or 8 digit number?

Answer that and you have a good idea what you need to test for. Think number, not digits.

Edited by WaltP: n/a

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.