Ç - 混合大小写字符串转换为全部小写 [英] c - convert a mixed-case string to all lower case

查看:324
本文介绍了Ç - 混合大小写字符串转换为全部小写的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是只为循环做一个通过每个位置迭代并调用 tolower的()上最好的/干净的方式?

is the best/cleanest way to just do a for loop iterating through each position and call tolower() on it?

推荐答案

这不是在标准库中,这是最直接的方法,我可以看到实现这样的功能,所以是。刚刚经历串回路,每个字符转换为小写。

It isn't in the standard library, and that's the most straight forward way I can see to implement such a function, so yes. Just loop through the string and convert each character to lowercase.

琐碎事情是这样的:

for(int i = 0; str[i]; i++){
  str[i] = tolower(str[i]);
}

或者如果你preFER单行,那么你可以使用这一个J.F.塞巴斯蒂安:

or if you prefer one liners, then you can use this one by J.F. Sebastian:

for ( ; *p; ++p) *p = tolower(*p);

这篇关于Ç - 混合大小写字符串转换为全部小写的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆