C++ primer plus第六版课后编程练习答案:8.3

#define  _CRT_SECURE_NO_WARNINGS 
#include 
#include
#include
#include
using namespace std;

void MyToupper(string& str1);

int main()
{
    string str;
    cout << "Enter a string (q to quit): ";
    getline(cin, str);
    //cout << str;
    //cin.get();
    while (str != "q")
    {
        MyToupper(str);
        cout << "Enter a string (q to quit): ";
        getline(cin, str);
        //cin.get();
    }
    cout << "Bye!\n";
}

void MyToupper(string& str1)
{
    int n = str1.length();
    for (int i = 0; i < n; i++)
    {
        str1[i]=toupper(str1[i]);
    }
    cout << str1<

你可能感兴趣的:(C++,primer,plus第六版课后编程练习)