If statement

I am writing some code. I need an if statement that basically states if a digit does not appear in this span of 80 characters, you will need one.

I am currently setting up an if statement inside my for loop. The for loop controls the length of the string that is being looked at. The if statement I currently have says:

if(isdigit(array[i]))


I need it to convert isdigit to a FALSE boolean statement (i.e. is"not"digit).

How do I do that?
if ( !isdigit(array[i]) )
How do I check if a digit exists within a specific range (40)
This is how I have it written, but this does not work.

for( i = 0; i <= 40; i++) {
if(!isdigit(Entered[i]))
cout << "The password must contain at least one digit" << endl;
}
The way I currently has it written produces that statement for each indices that are read. So if I enter 10 letters, the cout statement appears 10 times.
Note that range 40 spans index 0 through index 39.

1
2
3
4
5
6
for (i=0; i < 40; ++i)
    if (!isDigit(Entered[i]))
        break ;

if ( i != 40 )
    cout << "The password must contain at least one digit\n" ;


If you don't want something to happen multiple times, don't do it in a loop.
I want my code to look through my entire string and identify if there is a digit or not as well as a few other things. I am under the impression I will need to use isdigit at some point. My thought process was that a loop would cover the span of the desired section of the char string. I am not sure how to go about doing this without a loop.
I need the code to look through it all and produce certain statements depending on digit existence or not, etc.

Sorry, I'm still really new to all of this.
cire's code shows exactly that. The for loop checks that every char in the array is not a digit. If a char is a digit then the loop is left early (using break). If the loop is left early then i will not equal 40. So you then check (outside of the loop) if i is not equal to 40 i != 40 and print your error there.
Thank you so much for all of your help! This forum really is very helpful! I look forward to reading more that has been posted on this site and these forums!
Topic archived. No new replies allowed.