Thread: Raw vs. Cooked with getchar()

  1. #1
    Registered User
    Join Date
    Oct 2001
    Posts
    1

    Raw vs. Cooked with getchar()

    I am writing a charachter based game in C for Linux (using gcc)
    and I use getchar() to wait on the keyboard for a charactor. But It wont return untill I hit 'cr', This seems to be cooked behaviour, Is there a way to turn on raw behavour?


    Thanks

  2. #2
    Unleashed
    Join Date
    Sep 2001
    Posts
    1,765
    To wait on, and accept any character from the keyboard it's getch - not - getchar. getchar works, but getch works immediately and only accepts 1 character the moves on.
    The world is waiting. I must leave you now.

  3. #3
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,661
    1. Read this
    http://www2.linuxjournal.com/cgi-bin...termios&sect=1

    2. turn off the ICANON bit

    I think....
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. getchar() problem
    By jlharrison in forum C Programming
    Replies: 6
    Last Post: 01-25-2006, 02:49 PM
  2. getchar buffer size
    By oncemyway in forum C Programming
    Replies: 3
    Last Post: 08-02-2005, 12:49 AM
  3. getchar() problem from K&R book
    By anemicrose in forum C Programming
    Replies: 13
    Last Post: 04-04-2004, 11:06 PM
  4. help with getchar lol
    By Taco Grande in forum C Programming
    Replies: 5
    Last Post: 03-18-2003, 09:25 PM
  5. Can anybody take a look at this?
    By TerryBogard in forum C Programming
    Replies: 10
    Last Post: 11-21-2002, 01:11 PM