Created
September 28, 2011 20:15
-
-
Save mahata/1249132 to your computer and use it in GitHub Desktop.
C++ Primer 8.3
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <string> | |
#include <cctype> | |
using namespace std; | |
void capitalize_all(string & text); | |
int main() | |
{ | |
string text; | |
cout << "Enter a string (q to quit): "; | |
getline(cin, text); | |
if ("q" == text) { | |
cout << "Bye." << endl; | |
return 0; | |
} | |
capitalize_all(text); | |
cout << text << endl; | |
while (true) { | |
cout << "Next string (q to quit): "; | |
getline(cin, text); | |
if ("q" == text) { | |
cout << "Bye." << endl; | |
return 0; | |
} | |
capitalize_all(text); | |
cout << text << endl; | |
} | |
return 0; | |
} | |
void capitalize_all(string & text) | |
{ | |
for (int i = 0; i < text.size(); i++) { | |
text[i] = toupper(text[i]); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment