+ 5
How to use tolower() in C++?
To convert a string from uppercase to lowercase, tolower() function is a way. I wanna know about its header files and uses of this function.
12 Respostas
+ 3
Misbah Ahmed even std libraries rely on each other. so, itâs not surprising that you didnât need tolower() with std::transform(). writing a library function without header is bad programming practice. always include headers for specific functions even if they are visible to your code through other headers. Alphin K Sajan btw tolower() doesnât convert a string to a lowercase, rather it flips any uppercase char to lowercase.
+ 8
Misbah Ahmed Actually U need to include either <cctype> (c++) or <ctype.h> (c) to use functions like tolower()....
+ 7
tolower() is used to convert uppercase characters to lowercase .
It is defined in <cctype> header file
For more reference check this out:
https://www.programiz.com/cpp-programming/library-function/cctype/tolower
+ 7
Flash Nice catch....
+ 6
If u used it so , then consider it a bad practise..
Idk , Maybe it have worked bcos of the iostream header file ...
+ 4
Misbah Ahmed can you share you entire code here showing such behaviour
+ 4
Misbah Ahmed
I was told that some headers are included out of our consent as we include some headers. That is because the code in the included header needed the functionality provided by the other header we did not explicitly include.
https://www.sololearn.com/post/69831/?ref=app
0
But I used it with the function transform() and didn't need <cctype> header!!!
0
Nope, I included <algorithm> header for transform() function. And in the transform function, I used tolower as an argument without a parenthesis beside the tolower.
0
Like so,
transform(variable_name.begin(), variable_name.end(), variable_name.begin(), tolower)
0
I think you should use #include<string>
to work with string data types.
0
you can convert a string to lower without using tolower() function.