Okay, so my problem is that I'm making a program that identifies whether the user input is a letter, a number between 0-9 or a symbol.
This is what I have so far:
#include <iostream>
#include <iomanip>
#include <windows.h>
#include <string>
using namespace std;
int main()
{
char variable;
cout << "Enter a letter, symbol or number between 0-9: ";
cin >> variable;
cout << endl;
if(( variable >= '0') && (variable <= '9')) //Identifies if its a number between 0-9
{
cout << "You have entered: # " << variable << endl << endl;
}else{
(int)variable;
if( variable == 'a', 'z') //Identifies if its a letter
{
cout << "You have entered: " << variable << " à" << endl;
}
}
system("pause");
return 0;
}
Now what I need help with is two things. First, how do I identify if the input is a ASCII symbol. And second, since I'm using a variable that is a char, when the user enters a number longer than one digit it only records the first one, and if i change it to int, then I can't test whether its a letter or a ASCII symbol.
Please if anybody could answer ASAP. I really need this for tomorrow.