字母大小写转换可以不用循环吗

2011-03-22 wcdj

 

 

问题描述:
i wanna to make a prog which convert small case letters entered by user to upper case letters....i TRIED to use toupper function ...but it only do action with a single character...is there any function which convert all characters like "lovely hakeem" to "LOVELY HAKEEM"
(NOT BY LOOP)

There is no way to convert all characters to upper or lower case without looping through the string.

下面总结几种常用的大写转小写的方法

方法1:逐个字符判断,是大写字母+32

 

方法2:使用标准库算法transform

 

方法3:使用ctype中的函数

 

方法4:使用string中的函数 (NOT ANSI standard)

 

 

PS: A foreigner's method

 

更多内容参考:
http://www.cplusplus.com/forum/general/33439/
http://www.cplusplus.com/forum/beginner/14081/
http://topic.csdn.net/u/20071015/21/4c266542-c3a6-4a5a-9754-fc7574ca5ef6.html

 

 

 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值