将字符串中的第一个字母转换为大写 [英] Convert first letter in string to uppercase
本文介绍了将字符串中的第一个字母转换为大写的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有字符串,apple
。如何只将第一个字符转换为大写,并获得一个新的字符串赢得Apple
?
我也可以有一个包含多字节字符的字符串。
如果字符串的第一个字符是多字节字符,该怎么办?
I have string, "apple"
. How can I convert only the first character to uppercase and get a new string win the form "Apple"
?
I can have a string with multibyte characters also.
What if the first character of the string is multibyte character ?
推荐答案
string str = "something";
str[0] = toupper(str[0]);
这就是你需要做的。它也适用于C字符串。
That's all you need to do. It also works for C strings.
这篇关于将字符串中的第一个字母转换为大写的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文