I have tried to find out the difference between "getch" and "return" but i didn't get anything yet.
I have tried to find out the difference between "getch" and "return" but i didn't get anything yet.
They are completely unrelated, to be frank.
return is a keyword which, in broad terms, prepares a value for the calling function to use or store in a variable, and effectively ends the function at that point.
getch() is a non-standard input function, which if used, may affect the portability of your codebase. You will either be targeting windows or another platform with some version of a curses library. References for these common implementations are below:Code:int myrandom(void) { return 4; // value chosen by a fair die roll - guaranteed completely random }
_getch, _getwch
getch(3): char from curses terminal keyboard - Linux man page
Last edited by whiteflags; 03-02-2017 at 02:51 PM.
Not to appear condescending, but how can you not find differences between the two? What code were you using as reference?
( TC fossil incoming, I'd bet... )
Devoted my life to programming...