Quantcast
Channel: Programming Forums
Viewing all articles
Browse latest Browse all 51036

simple char length

$
0
0
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 :
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.

Viewing all articles
Browse latest Browse all 51036

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>