Is there keyboard input that is not considered char?

Thanks for taking the time to read this first of all,

I am currently writing a driver program for a class in C ++, and I need some input from the user. I started using typedefverification programs to create programs, so I can easily switch between different types. For the specific problem I'm working on, I found that I only work with char, which leads me to my questions:

  • My check checks if there is an input char. Is using validation pointless if I know that I'm just working with charin particular? Everything the user enters is similar to char.

  • Is there anything that the user can enter into it will not be considered char?

This question may seem a little trivial, but I have never thought about it before! Still learn the language, so any guidance is appreciated.

The code in question (ElementType is of type char):

void getInput( ElementType & cho )
{
    while ( !(cin >> cho) )
    {
        cout<< "That is an invalid input..."
            << "\nTry again: ";
    }
    cout<< endl;
}
+4
source share
2 answers

Is there anything the user can enter into it that will not be considered char?

Yes: Shift, Ctrl, Alt, Num Lock, to name a few.

, - , - . ( ) char cin/stdin. , , ++.

, cin 256 char, '\0', cin - , , , . , . char.

?

. char - char. , , char, a char ASCII 0 127 char . , .

+1

Linux, UTF-8, , , , char. . รก . , .

. ASCII.

-1

Source: https://habr.com/ru/post/1612818/


All Articles