C++tolower function usage summary
Published: 2019-05-09

c++ has a function tolower.This function is a function that processes strings.Converts uppercase to lowercase. Upcase refers to ABCDEFGHIJKLMNOPQRSTUVMXYZ converted to abcdefghijklmnopqrstuvwxyz.Non-alphabetic characters are not processed.For example, 1, 2, 3!Equal characters are header files that are output in the original characters: in VC6.0, they can be ctype.h or stdlib.hOf course, this function is a bit special in its usage. It deals with characters, not strings.The so-called inability to process strings does not mean that he cannot process strings. When he processes strings, he must process them character by character and cannot process strings at one time.The following procedure also illustrates this problem.

One thing needs to be explained here is that the string str inside here contains a transition character'' \n', and no transition character will be output here. This transition character is a special output or a transition character, that is to say, the function of the transition character after output 123 or the function of the transition character,

The final result is: (The following two methods are used to output str. The answer is the same, so only one result is output again)

test string123


press any key to continue。...

You can run it yourself, and learn to draw inferences from other cases that you don't understand.

#include <stdio.h>

#include <ctype.h>

int main ()


int i=0;

char str[]="Test String123.\n\n";In this case, the conversion symbol is unchanged, no matter what kind of style is used for output.
char c;
//char c[20]=tolower(str);//cannot directly convert arrays or strings to lowercase

while (str[i])


printf ("%c",c);
putchar (tolower(c));



return 0;