tolower c语言,C语言 tolower()用法及代码示例

tolower()函数在ctype.h头文件中定义。如果传递的字符是大写字母,则tolower()函数会将大写字母转换为小写字母。

用法:

int tolower(int ch);

参数:此方法采用强制参数ch,该参数是要转换为小写字母的字符。

返回值:此函数返回对应于ch的小写字符。

以下示例程序旨在说明C语言中的tolower()函数:

示例1:

// C program to demonstrate

// example of tolower() function.

#include

#include

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

#include

int main()

{

int j = 0;

char str[] = "GEEKSFORGEEKS\n";

// Character to be converted to lowercase

char ch = 'G';

// 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;

}

输出:

geeksforgeeks

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值