getch() and ungetch() ?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • cworld
    New Member
    • Jan 2007
    • 15

    getch() and ungetch() ?

    when i use getch , then it reads the data from the keyboard but it does not display it on screen as in the case of getchar(). So should i use ungetch() or some thing else.
    but the program executes well and give output other then the current entered data from the keyboard.
    Plz help

    Regard
    cworld.
  • horace1
    Recognized Expert Top Contributor
    • Nov 2006
    • 1510

    #2
    Originally posted by cworld
    when i use getch , then it reads the data from the keyboard but it does not display it on screen as in the case of getchar(). So should i use ungetch() or some thing else.
    but the program executes well and give output other then the current entered data from the keyboard.
    Plz help

    Regard
    cworld.
    Text streams in C operate on a line by line basis with characters entered being placed in an input buffer until newline (or end of file) is entered. The next character can then be read by getchar (or scanf) and passed to the program.

    Some C systems have functions which will read individual characters directly from the keyboard, e.g. MicroSoft C and Borland Turbo C have functions getche (echo character) and getch (no echo) in <conio.h>. It is recommended that you don't use getch() or getche() if you wish your code to be portable.

    Comment

    • cworld
      New Member
      • Jan 2007
      • 15

      #3
      Originally posted by horace1
      Text streams in C operate on a line by line basis with characters entered being placed in an input buffer until newline (or end of file) is entered. The next character can then be read by getchar (or scanf) and passed to the program.

      Some C systems have functions which will read individual characters directly from the keyboard, e.g. MicroSoft C and Borland Turbo C have functions getche (echo character) and getch (no echo) in <conio.h>. It is recommended that you don't use getch() or getche() if you wish your code to be portable.
      Thankyou so much horace!
      now i understand the concept of getch() and getchar very well
      Thanx once again

      Regards
      cworld

      Comment

      Working...