Raw vs. Cooked with getchar()

This is a discussion on Raw vs. Cooked with getchar() within the C Programming forums, part of the General Programming Boards category; I am writing a charachter based game in C for Linux (using gcc) and I use getchar() to wait on ...

  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 wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,505
    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.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

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, 01: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, 08:25 PM
  5. Can anybody take a look at this?
    By TerryBogard in forum C Programming
    Replies: 10
    Last Post: 11-21-2002, 12:11 PM

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