I wanted to know how to change a string from uppercase to lower case without a loop. I've been trying to look for a solution online but cant find one. I thought this would work but I keep getting a ‘std::string’ has no member named ‘tolower’ error. please help
The tolower function applies to character arrays, not strings. Now, if you want to use tolower with a string, you will need to use std::transform, which is in the algorithm library. Specifically, it would be written as thus:
And if you are not allowed to use transform you can loop through each character in the string. Also if you read on the tolower function it takes a parameter of a character and it is not a member function of the string class but from the cctype library. http://www.cplusplus.com/reference/cctype/tolower/?kw=tolower
So the way to do it without the algorithm would be:
1 2 3 4
for( int i = 0; i < SIZE_OF_STRING; ++i )
{
some_string[i] = tolower(some_string[i];
}