Difference in C

This is a discussion on Difference in C within the C Programming forums, part of the General Programming Boards category; what is the difference between getc(),getch(),getche().... similarly putc(),putch(),putche()........

  1. #1
    Registered User
    Join Date
    Nov 2009
    Posts
    11

    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
    Posts
    9,796
    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, 05:36 PM
  3. Difference Equations / Recurrence Relations
    By DavidP in forum A Brief History of Cprogramming.com
    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, 05:55 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21