123456789101112131415161718192021222324
#include <iostream> #include <string> #include <cstring> #include <algorithm> using namespace std; int main() { const int SENTENCE = 20; char sentence[SENTENCE]; cout << endl << "Enter a sentence: " << endl; cin.getline(sentence, SENTENCE); cout << "You entered: "; for(int i = 0; i < SENTENCE; i++) { cout << sentence[i]; } //system("pause"); // pause system return 0; }
cout << toupper(sentence[i]);
12345678910111213141516171819202122
int main (void) { const int SENTENCE = 20; char sentence[SENTENCE]; cout << endl << "Enter a sentence: " << endl; cin.getline (sentence, 20); cout << "You entered: "; int I = 0; while ( I < SENTENCE && sentence [I]) { if ( sentence [I] != ' ') sentence [I] &= 0x5f; I++; } cout << sentence << endl; return 0; }