c++string字符串的输出

来源:互联网 发布:mac上有没有hgame 编辑:程序博客网 时间:2024/05/17 07:39
#include<iostream>
#include<string>
#include<cctype>
using namespace std;
int main()
{
string s("some stringh");
//法1:
//if(!s.empty())
//s[0]=toupper(s[0]);
//法2:
//if(s.begin()!=s.end()){
//auto it=s.begin();
//*it=toupper(*it);
//}
//法3:将 some 转换成大写
for(auto it=s.begin();it!=s.end()&&!isspace(*it);it++)
*it=toupper(*it);
cout<<s<<endl;
system("pause");
}
0 0
原创粉丝点击