Write your question here.
hi, i'm a beginner from the root of the tree, and i cannot solve this project for days now, help is needed.
when i compile, the msg < [Linker error] undefined reference to `testUpper(char)'
shows up
thank you
Maybe instead of using a char password[] as the type of the argument for the toUpper function why don’t you try out char *? I’m not entirely sure that will work, but might as well
char ptrPass;
char password[Size];
cout <<"Enter a password:";
cin >> password;
ptrPass = password[Size]; //this is a memory access error. c++ is 0 to size-1
testLength(ptrPass); //void testLength(char password[]) type mismatch char array vs char
testUpper(ptrPass); //as above
testLower(ptrPass); //and again
what is it you want to DO? Do you want to ensure that a word has one uppercase letter, one lower, one special? If so, then iterate all the letters in it until you see if it has them.
If you wanted performance, you would loop over the letters once like this:
1 2 3 4 5 6 7 8 9
bool special = false; bool upc=false; bool lowc=false;
for(int x = 0; x < strlen(password) && !(special&&upc&&lowc); x++)
{
// check each letter and set appropriate Boolean for it
special |= issspecial(password[x]); //looks like you were asked to write these
upc |= isupper(password[x]);
lowc |= islower(password[x]);
}
return special&&upc&&lowc; //return true if it has all 3 else false.
cin >> password; this is also at risk of memory problems if user types 20 letters etc. this is a risk when using c-strings. You should use string c++ type once you cover that in your studies. You may want to make it extra long like 100 chars for now just as a precaution.