tolower() function converts characters to lowercase, accepts ASCII code values and returns the corresponding lowercase version. This function is often used to convert a string to lowercase. The parameter is the ASCII code value of the string. If the input is an uppercase letter, lowercase is returned. If it is a lowercase letter or non-letter, the original value is returned.
Usage of tolower in C language
tolower() function is used to convert characters in the C standard library Lowercase functions. It accepts an ASCII value of type int as a parameter and returns the lowercase version of the character. If the input is not an ASCII value, the original value is returned.
Syntax:
<code class="c">int tolower(int c);</code>
Parameters:
c
: The character to be converted ASCII code value. Return value:
Usage:
tolower() function is often used to convert strings to lowercase. Here is an example:
<code class="c">#include <stdio.h> #include <string.h> int main() { char str[] = "THIS IS A STRING"; // 将字符串转换为小写 for (int i = 0; i < strlen(str); i++) { str[i] = tolower(str[i]); } printf("小写字符串:%s\n", str); return 0; }</code>
Output:
<code>小写字符串:this is a string</code>
The above is the detailed content of How to use tolower in c language. For more information, please follow other related articles on the PHP Chinese website!