吾爱程序员:这里有好玩的游戏和软件
当前位置:首页C语言教程 → C语言中的tolow()函数

C语言中的tolow()函数

来源:网络 | 更新时间:2022-01-15 20:13:55
tolower()函数在ctype.h文件中定义。如果传递的字符是大写字母,则 tolower() 函数将大写字母转换为小写字母。 语法: 
int tolow(int ch);
参数:该方法需要一个强制参数ch,它是要转换为小写的字符。 返回值:该函数返回ch对应的小写字符。 下面的程序说明了 C 中的 tolower() 函数: 示例 1:-
// C program to demonstrate
// example of tolower() function.

#include <ctype.h>
#include <stdio.h>

int main()
{

// Character to be converted to lowercase
char ch = 'G';

// convert ch to lowercase using toLower()
printf("%c in lowercase is represented as = %c", ch, tolower(ch));

return 0;
}
输出: 
G in lowercase is represented as = g
示例 2:-
// C program to demonstrate
// example of tolower() function.

#include <ctype.h>
#include <stdio.h>

int main()
{
int j = 0;
char str[] = "CXYDHn";

// Character to be converted to lowercase
char ch = 'C';

// convert ch to lowercase using toLower()
char ch;

while (str[j]) {
ch = str[j];

// convert ch to lowercase using toLower()
putchar(tolower(ch));

j++;
}

return 0;
}
输出: 
cxydh
笔记:   如果在 tolower() 中传递的字符是这三个中的任何一个 1.小写字符 2.特殊符号 3. 数字 tolower() 将按原样返回字符。 例子 :
// C program to demonstrate
// example of tolower() function.
#include <ctype.h>
#include <stdio.h>

int main()
{
int j = 0;
char str[] = "Cxydh@123n";
char ch;

while (str[j]) {
ch = str[j];
putchar(tolower(ch));
j++;
}

return 0;
}
输出
cxydh@123
 

最新文章

热点资讯

手游排行榜

CopyRight 2020-2030吾爱程序员

鄂ICP备2021004581号-8

本站资源收集于网络,如有侵权请联系我们:35492删除0109@qq.com