char length :|

Hello guys :)
My question is how can I verify the lenght of a simple char.Rather i wont to know if the char is empty(that means,that the user pressed ENTER),or the char is entered.With other words i wont to know the strlen of a char.It can be 0 or 1.
I hope you understand what i wont :
1
2
3
4
5
6
7
8
int main() {
char semn;
cin>>semn;
if(strlen(semn)==0) { //here is my problem
cout<<"anything";
}
return 0;
}

If the user pressed ENTER ,it displays "anything" but if he enter a character for exeample,the program closes.
I need this in a program that adds or subtracts numbers,the user enters here the "semn" char,it can be '+' or '-'.If he presses ENTER,the result will be displayed.I will write this program,you try please to answer my question.
A char can never be empty. It always has a value.

I doubt the code even compiles. When you read a char like that you will get the next non-whitespace character. Pressing enter without having entered any other characters will not do anything. It will just continue waiting for more input.
A single character cannot have a length.
You must use a character array (a sequence of chars) to do so, or a std::string.
Topic archived. No new replies allowed.