C++はどのように文字列の中の小文字を大文字に変えます

2571 ワード

       
#include<iostream>
#include<string>
#include<cctype>
using namespace std;
int main()
{
string s("Hello World");
cout << s << endl;
for (auto c : s)
{
c = toupper(c);
cout << c;
}
return 0;
}
#include<iostream> 
using namespace std; 
void main() 
{
char x;
cout<<"       :"<<endl;
cin>>x;
if((x>='a')&&(x<='z'))
{x=x-32;<br>cout<<x<<endl;}

}

大文字に変換
#include <iostream>int main()
{
char str[5] = "TesT";
for(unsigned int i = 0; i < strlen(str); i++)
if(str[i] >= 'A' && str[i] <= 'Z')//     
str[i] += 32;//   
std::cout << str << std::endl;
return 0;
}