Convert first letter in string to uppercase

后端 未结 5 1118
隐瞒了意图╮
隐瞒了意图╮ 2020-12-02 23:27

I have a string: \"apple\". How can I convert only the first character to uppercase and get a new string in the form of \"Apple\"?

I can al

5条回答
  •  误落风尘
    2020-12-03 00:15

    string str = "something";
    str[0] = toupper(str[0]);
    

    That's all you need to do. It also works for C strings.

提交回复
热议问题