Thread: Difference in C

  1. #1
    Registered User
    Join Date
    Nov 2009

    Difference in C

    what is the difference between

    getc(),getch(),getche().... similarly putc(),putch(),putche().....

  2. #2
    Code Goddess Prelude's Avatar
    Join Date
    Sep 2001
    getc and putc are standard, getch/putch and friends are not. But assuming you use a compiler where getch and friends are supported, the difference is usually as follows:
    • getc/putc - Works through the standard C stream framework and are not limited to the keyboard and console.
    • getch/putch - Works directly with the keyboard buffer/console, respectively.

    Further, getch differs from getc in behavior because the C stream framework is typically line buffered (this comes from the underlying shell) and input will not be sent to the program until a newline is detected. Thus getch and getche are ways to read a single character immediately without requiring the user to press the enter key.

    Finally, getch and getche differ in that getch reads a character without echoing it to the screen while getche does echo the character. getc follows the rules of the underlying shell, which usually echoes the characters being typed.
    My best code is written with the delete key.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Review required for program of date difference
    By chottachatri in forum C Programming
    Replies: 6
    Last Post: 10-31-2008, 11:46 AM
  2. Finding the difference in two times
    By muthus in forum C++ Programming
    Replies: 4
    Last Post: 01-24-2008, 06:36 PM
  3. Difference Equations / Recurrence Relations
    By DavidP in forum A Brief History of
    Replies: 4
    Last Post: 10-05-2007, 10:26 AM
  4. What's the difference between var++ and ++var
    By ulillillia in forum C Programming
    Replies: 6
    Last Post: 05-31-2007, 02:27 AM
  5. What is the Difference between ANSI C and non-ANSI C ?
    By Unregistered in forum C Programming
    Replies: 1
    Last Post: 11-24-2001, 06:55 AM