您的位置:首页 > 编程语言 > C语言/C++

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

2016-10-06 13:16 375 查看
#define  _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include<cctype>
#include<string>
#include<cstring>
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<<endl;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  c语言