/*
Enter a string <q to quit>: go away 123
GO AWAY 123
Next string <q to quit>: good grief!
GOOD GRIEF!
Next string <q to quit>: q
Bye.
*/
#include <iostream>
#include <cstring>
using namespace std;
void stringToUpper(string &);
int main() {
string toUpperLetter;
cout << "Enter a string <q to quit>: ";
while (true) {
getline(cin, toUpperLetter);
if (toUpperLetter == "q") {
cout << "Bye.\n";
break;
}
else {
stringToUpper(toUpperLetter);
cout << toUpperLetter << "\n";
cout << "Next string <q to quit>: ";
}
}
return 0;
}
void stringToUpper(string & s) {
for (int i = 0; i != '\n'; i++)
s[i] = toupper(s[i]);
}
c++ primer plus 第八章《编程题8.8.3》
最新推荐文章于 2022-09-30 22:13:02 发布