自己写的,如有错误,欢迎指正~~~
#include<iostream>
#include<string>
#include<cctype>
using namespace std;
//prototype
void change(string & str);
//main
int main()
{
string str;
cout << "Enter a string (q to quit): ";
getline(cin,str);
while (str != "q" && str != "Q")
{
change(str);
cout << "\nNext string (q to exit): ";
cin >> str;
}
cout << "Bye!" << endl;
system("pause");
return 0;
}
//function
void change(string & str)
{
int size = str.size();
for (int i = 0; i < size;i++)
{
if (islower(str[i]))
str[i] = toupper(str[i]);
cout << str[i];
}
}