I'm trying to convert a string to lowercase, and am treating it as a char* and iterating through each index. The problem is that the tolower
function I read about online is not actually converting a char to lowercase: it's taking char as input and returning an integer.
cout << tolower('T') << endl;
prints 116
to the console when it should be printing T
.
Is there a better way for me to convert a string to lowercase?
I've looked around online, and most sources say to "use tolower
and iterate through the char array", which doesn't seem to be working for me.
So my two questions are:
What am I doing wrong with the
tolower
function that's making it return 116 instead of 't' when I calltolower('T')
Are there better ways to convert a string to lowercase in C++ other than using
tolower
on each individual character?