I am working on a password project for school, and I am stumped on one part. I know how to test if a string (or file) contains a digit, or a letter, but in this case we have to verify that there is at least one character that is not a letter. Any clue to how I could do this?
yankeetooter7 0 Newbie Poster
Recommended Answers
Jump to PostLook at first character. If it's not a letter, then there is at least one character that is not a letter. Stop now. If it is a letter, move on to next character.
Next character: Look at it. If it's not a letter, then there is at least one character …
Jump to PostGet all characters first into a single string, then examine them.
Jump to Poststring input; cin >> input; for (int i=0; i< input.length(); i++) { if (!isalpha(input[i])) { // this is NOT a letter. Do something } }
Jump to Post
for (index = 0; index < password.length(); index++)
For all letters in the passwordif(isalpha(password[index]))
if any letter IS alphanumericif(index = password.length()
set the value of index to length (so that we stop looping?), but why do it in an if construct? This is just misleading and asking for trouble - …
Jump to PostSimplify your code. Much, much simpler. Really simple.
The following code is simple. Get password, examine every character, check at end to see if there was a "bad" character.
string password; int passwordIsBad; int passwordContainsAtLeastOneNonAlphabeticChar; do{ passwordContainsAtLeastOneNonAlphabeticChar = 0; passwordIsBad = 0; // assume it's fine at …
All 26 Replies
Moschops 683 Practically a Master Poster Featured Poster
yankeetooter7 0 Newbie Poster
Moschops 683 Practically a Master Poster Featured Poster
yankeetooter7 0 Newbie Poster
Moschops 683 Practically a Master Poster Featured Poster
yankeetooter7 0 Newbie Poster
NathanOliver 429 Veteran Poster Featured Poster
yankeetooter7 0 Newbie Poster
yankeetooter7 0 Newbie Poster
Moschops 683 Practically a Master Poster Featured Poster
yankeetooter7 0 Newbie Poster
Moschops 683 Practically a Master Poster Featured Poster
yankeetooter7 0 Newbie Poster
yankeetooter7 0 Newbie Poster
Moschops 683 Practically a Master Poster Featured Poster
yankeetooter7 0 Newbie Poster
yankeetooter7 0 Newbie Poster
Moschops 683 Practically a Master Poster Featured Poster
yankeetooter7 0 Newbie Poster
k99rs 9 Newbie Poster
yankeetooter7 0 Newbie Poster
yankeetooter7 0 Newbie Poster
Moschops 683 Practically a Master Poster Featured Poster
yankeetooter7 0 Newbie Poster
k99rs 9 Newbie Poster
yankeetooter7 0 Newbie Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.