Hi, I am trying to do a simple if/else input validation but the codes i used only seem to work one way.
The code will work if I want a number and the user input a letter, but it will not work if I ask the user to enter a letter and they input a number.
If i change char to int , it will work as normal, but if I leave it as char, the program will think there are no problems.
#include <iostream>
using namespace std;
int main ()
{
char character;
cout << "Enter a letter: ";
cin >> character;
if (cin.fail())
cout << "failed" << endl;