

目标→黑客←努力 qq群281123877,讨论 奋斗!
#include <iostream> #include <string> #include <cctype> using namespace std; string Upper(string & s); int main() { cout<<"Enter a string (q to quit): "; string str; getline(cin,str); Upper(str); //只改了这里到 while(str!="Q") { cout<<str<<endl; cout<<"Next string (q to quit): "; getline(cin,str); Upper(str); } //这里。目测可行。 cout<<"Bye.\n"; return 0; } string Upper(string &s) { char *pStr = (char *)s.c_str(); while(*pStr) { *pStr = toupper(*pStr); pStr++; } return s; }