A Solution to IsLowercase(); checking with Ascii code

bool FBullCowGame::IsLowercase(Fstring word) const
{
	if (word.length() <= 1) { return true;}; // make sure word length is over 0

	int AsciiValue = 96; // Ascii character 'a' holds value of 97
	for (auto letter : word)
	{
		//for every entered character subtract from 'AsciiValue'
		//If it is lowe than 0 - or greater than 26; it is not a lower case letter
		if ((AsciiValue - letter > 0) || (letter - AsciiValue >26))
		{
			return false;
		}
	}

	return true;
}

Privacy & Terms