I have seen in different text/source code that a variable that will get the getchar() result is declared in some code listings as int and in other code listings as char.
Which is the proper approach?
Thank you.
I have seen in different text/source code that a variable that will get the getchar() result is declared in some code listings as int and in other code listings as char.
Which is the proper approach?
Thank you.
The type of variable that stores the result of getchar should match the return type of getchar (int). Read through the documentation here for the details: getchar(3): input of char/strings - Linux man page.