IsLowerCase() implemented

bool FBullCowGame::IsLowerCase(FString Word) const
{
	//Check for zero length strings or /0
	if (Word.length() == 0) { return true;}
	//loop through the letters of the word
	for (auto Letter : Word) 
	{
		//check if the letter is not lowercase
		if (!islower(Letter)) 
		{
			//the word is not all lower case!
			return false;
		}
	}
	//made it through the loop so assuming it is all lowercase
	return true;
}

and now I realized I put nothing in to check for spaces :stuck_out_tongue:

Try this!

result = std::find_if(Word.begin(), Word.end(), ::islower ) != Word.end();

Short and sweet

Privacy & Terms