Here is one of the functions in a program I am writing. For some reason I cannot figure out why the for loop wont run. The for loop is right before the return, any advice related or not is appreciated. The lines cout << userInput[i] << " " << i <<endl; where just for me to see if anything is happening in the loop and like expected they did not show up.
//define the nameInfo function. Part is set in the Main function to let us know what we are here for
string nameInfo (string part){
//create a variable to hold the users answer
string userInput;
//set a variable to know when to exit the loop
bool finished = false;
//put this in a while loop to allow changes
while (finished == false){
//Prompt the user to enter a name
cout <<
" \n Now please enter your " << part << " name.";
//Assign users input to a variable use cin instead of getline to only get the first name incase user types more
cin >> userInput;
//check to see if the entered input has any numbers in it.
if (userInput.find_first_of("0123456789") != userInput.npos){
//if in here the name has a number in it
//clear the screen of clutter
system("CLS");
//prompt the user to try again
cout << " \n Sorry the name you have entered cannot be accepted. \n Please only use letters A-Z.";
}else{
//name is good set finished to true
finished = true;
}
}
//Make sure each letter case is propper
for (int i = 0; i > userInput.length();i++){
//if it is the first letter we capitalize it
if (i == 0){
//this is taking the first letter (i at zero) and making it a capital
userInput[i] = toupper(userInput[i]);
cout << userInput[i] << " " << i <<endl;
//if it is not the first letter then do this
}else{
//this makes every character except the first one lower
userInput[i] = tolower(userInput[i]);
cout << userInput[i] << " " << i <<endl;
}
}
return (userInput);
}