Input number keyboard

Hi…
how is possible that the input of key function is only and any number, and have it like output ?

like this:
if( key == " only and any number")
{
cout<<" only and any number"
}

thanks…

Hi there!

I’m sorry, but I’m not sure of what you exactly want. This?

if (key == 50 /* or ‘2’ */) cout << key << endl;

do you mean like this?:

if(isdigit(key)) {
    cout << key << endl;
}

that will check if the input is a digit. Returns true on 0-9 and returns false on anything else.

http://www.cplusplus.com/reference/cctype/isdigit/

sorry for the long waiting

if(isdigit(key)) {
cout << key << endl;
}

it was what i needed

:smile: