前言:C++中的字符串大小写转换没有Java中的方便,但究其根本其实用个阿斯克码也能做,非常简单,这里贴一个tolower和toupper的方法,都是比较简单的知识点,但确是我这种Java转C++选手存在的一些盲点
将一个字符串转为全部大写#includeusing namespace std; int main(){ ios::sync_with_stdio(0),cin.tie(0),cout.tie(0); string s="aBasasa"; for(auto &c: s){ c=toupper(c); } cout< 输出:ABASASA
将一个字符串转为全部小写#includeusing namespace std; int main(){ ios::sync_with_stdio(0),cin.tie(0),cout.tie(0); string s="aSJAISJAISa"; for(auto &c: s){ c=tolower(c); } cout< 输出:asjaisjaisa



