Thread: How do I input an unbuffered character via the keyboard???

  1. #1
    Registered User
    Join Date
    Mar 2008
    Posts
    1

    Unhappy How do I input an unbuffered character via the keyboard???

    I am using Nios II to program the Altera DE2 board using C, along with a PC running Windows. The user must enter a number via the PC's keyboard. Every time the user enters a number, I want to immediately display it on the DE2's seven-segment LED display.

    Sounds simple, right? But there's a problem... when I get the character using the getchar() function, the user must hit the Enter key in order for the program to get the character. I don't want this... I want to get the character immediately after the user presses the key. I don't want the user to have to press the Enter key in order for the program to get the character.

    How do I do this? I think the problem is that getchar() is a "buffered" function. I want unbuffered input.

    There is a function called getche() that I think would do the trick. But it is part of <CONIO.H>, and Nios apparently doesn't support it.

  2. #2
    Dr Dipshi++ mike_g's Avatar
    Join Date
    Oct 2006
    Location
    On me hyperplane
    Posts
    1,218
    I think ncurses can do that for you, but AFAIK theres no way of doing it using the standard libraries.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Keyboard Input
    By CaliJoe in forum C++ Programming
    Replies: 3
    Last Post: 05-08-2009, 09:51 AM
  2. Do While Character Input Error
    By crackpat in forum C Programming
    Replies: 2
    Last Post: 04-13-2009, 11:22 PM
  3. Need some help with C program writing
    By The_PC_Gamer in forum C Programming
    Replies: 9
    Last Post: 02-12-2008, 09:12 PM
  4. Reading input from keyboard
    By Pests in forum C++ Programming
    Replies: 5
    Last Post: 11-01-2005, 11:57 AM
  5. Linux: Send keyboard input to background process
    By xErath in forum Tech Board
    Replies: 2
    Last Post: 12-09-2004, 07:02 PM