Thread: What is the difference between "getch" and "return"?

  1. #1
    Registered User
    Join Date
    Feb 2017
    Posts
    4

    What is the difference between "getch" and "return"?

    I have tried to find out the difference between "getch" and "return" but i didn't get anything yet.

  2. #2
    Lurking whiteflags's Avatar
    Join Date
    Apr 2006
    Location
    United States
    Posts
    9,612
    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.
    Code:
    int myrandom(void)
    {
       return 4; // value chosen by a fair die roll - guaranteed completely random
    }
    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:
    _getch, _getwch
    getch(3): char from curses terminal keyboard - Linux man page
    Last edited by whiteflags; 03-02-2017 at 02:51 PM.

  3. #3
    Programming Wraith GReaper's Avatar
    Join Date
    Apr 2009
    Location
    Greece
    Posts
    2,738
    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...

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 2
    Last Post: 12-08-2014, 08:12 PM
  2. Can't get "return()" to work.Problem in "if" part
    By coder1 in forum C Programming
    Replies: 13
    Last Post: 09-10-2013, 01:08 AM
  3. Replies: 2
    Last Post: 08-19-2012, 06:15 AM
  4. "itoa"-"_itoa" , "inp"-"_inp", Why some functions have "
    By L.O.K. in forum Windows Programming
    Replies: 5
    Last Post: 12-08-2002, 08:25 AM
  5. "CWnd"-"HWnd","CBitmap"-"HBitmap"...., What is mean by "
    By L.O.K. in forum Windows Programming
    Replies: 2
    Last Post: 12-04-2002, 07:59 AM

Tags for this Thread