Why isnt the toupper working?
I need it so even if you enter a capital Y instead of a lowercase y it just makes it all uppercase. Im trying to do this in line 36
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57
|
#include <iostream>
#include <string>
#include <conio.h>
#include <iomanip>
using namespace std;
int main()
{
char response;
int value = 0;
char msg1[80] = "";
char msg2[80] = "";
do
{
cout << "Enter a phrase: "; //get phrase one
cin.getline(msg1, 80);
cout << "\nEnter another phrase: "; //get phrase two
cin.getline(msg2, 80);
cout << "\nPhrase \"" << msg1 << "\" has " << strlen(msg1) << " characters."; //display amount of characters
cout << "\n\nPhrase \"" << msg2 << "\" has " << strlen(msg2) << " characters.";
value = strcmp(msg1, msg2);
if(value == 0)
cout << "\n\nIn C++, phrase \"" << msg1 << "\" is equal to the phrase \"" << msg2 << "\""; //determine which phrase is greater
else if(value > 0)
cout << "\n\nIn C++, phrase \"" << msg1 << "\" is greater than the phrase \"" << msg2 << "\"";
else if (value < 0)
cout << "\n\nIn C++, phrase \"" << msg2 << "\" is greater than the phrase \"" << msg1 << "\"";
cout << "\n\nPlay again(y/n)? ";
cin >> response;
toupper(response);
cout << response;
while(response != 'Y' || response == 'N')
{
if(response == 'N')
{
cout << "\n\nprogram ends.";
break;
}
cout << "\nEnter a valid option: ";
cin >> response;
toupper(response);
}
}
while(response == 'Y');
_getch();
return 0;
}
|
response = toupper(response);
Topic archived. No new replies allowed.