Today I've been having trouble using toupper. Can somebody point out what's wrong? I made a little example in Visual Studio quickly, it isn't what all my code looks like!
Thanks for the help everybody.
Thanks for the help everybody.
/*Enter anything. If you type n, or N, success should show up! Anything else should show failure.
n
Failure...
Press any key to continue . . .
Enter anything. If you type n, or N, success should show up! Anything else should show failure.
N
Success!
Press any key to continue . . .*/
#include <iostream>
using namespace std;
int main()
{
char variable = 'n';
cout << "Enter anything. If you type n, or N, success should show up! Anything else should show failure.\n";
cin >> variable;
if (toupper(variable == 'N'))
cout << "Success!\n";
else
cout << "Failure...\n" ;
system("pause");
return 0;
}
n
Failure...
Press any key to continue . . .
Enter anything. If you type n, or N, success should show up! Anything else should show failure.
N
Success!
Press any key to continue . . .*/
#include <iostream>
using namespace std;
int main()
{
char variable = 'n';
cout << "Enter anything. If you type n, or N, success should show up! Anything else should show failure.\n";
cin >> variable;
if (toupper(variable == 'N'))
cout << "Success!\n";
else
cout << "Failure...\n" ;
system("pause");
return 0;
}