首页 > 试题广场 >

编写一个函数,用string对象作为参数,将string对象

[问答题]

编写一个函数,用string对象作为参数,将string对象转换为全部大写。

推荐
#include <string>
#include <cctype>
using namespace std;
void ToUpper(string & str)
{
      for (int i = 0; i < str.size(); i++)
           str(i) = toupper(str[i]);
}

发表于 2018-09-03 20:34:32 回复(0)