且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

假设用一个名为text的字符串向量存放文本文件的数据,其中的元素或者是一句话或者是一个用于表示段分隔的空字符串。将text中第一段全改为大写形式

更新时间:2022-05-17 05:02:27

#include<iostream>
#include<string>
#include<vector>
using namespace std;
int main()
{
    vector<string> str={"The is C++ program ","hfh ","","hfdshfisoid"};
    for(auto it=str.begin();it!=str.end()&&!it->empty();++it)
    {
        cout<<*it<<endl;
        for(auto st=(*it).begin();st!=(*it).end();++st)
        {
            *st=toupper(*st);
        }
        cout<<*it<<endl;
    }

    return 0;
}

运行结果:

假设用一个名为text的字符串向量存放文本文件的数据,其中的元素或者是一句话或者是一个用于表示段分隔的空字符串。将text中第一段全改为大写形式