You can use it without forced conversion, but a warning will be reported during compilation, so the program will not be robust. In order to make the program better and more robust, I still converted it and used it. In fact, the most fundamental reason is Or because integers and characters are equivalent in the range 0-255.
As for the getchar() function, I want you to take a look at its prototype implementation. See the C language manual. He is reading Enter a character and return to determine whether the end of the file has been read. When the value is EOF (==-1), it means the end of the file has been read, and exception handling is required.
Hope it helps you and seek the best