I am trying to convert a string to lowercase, and treat it as char * and iterate through each index. The problem is that the function tolowerI read on the Internet does not actually convert char to lowercase: it takes char as input and returns an integer.
cout << tolower('T') << endl;
prints 116to the console when it should print T.
Is there a better way to convert a string to lowercase? I looked on the Internet, and most sources say that “use tolowerand iterate through a char array”, which does not seem to work for me.
So my two questions:
What am I doing wrong with a function tolowerthat forces it to return 116 instead of "t" when calledtolower('T')
Are there any better ways to convert a string to lowercase in C ++, other than using tolowerfor each individual character?
source
share