c++ primer plus 第八章《编程题8.8.3》

来源:互联网 发布:手机mac地址修改器 编辑:程序博客网 时间:2024/06/03 21:34
/* 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]);}
0 0