Thread: reading in char values?

  1. #1
    Registered User Daniel's Avatar
    Join Date
    Jan 2003
    Posts
    47

    reading in char values?

    How do I go about reading in a character value without the user having to press enter?

    Thank you for your help,
    Daniel

  2. #2
    Registered User subdene's Avatar
    Join Date
    Jan 2002
    Posts
    367
    Code:
    #include <iostream.h>
    
    int main(void)
    {
      char C;
    
      cout << "Please enter char: ";
      cin >> C;
    
      cout << "\n" << C;
    
      cin.get() //hold screen
    
      return 0;
    }
    Be a leader and not a follower.

  3. #3
    I lurk
    Join Date
    Aug 2002
    Posts
    1,361

    Re: reading in char values?

    Originally posted by Daniel
    How do I go about reading in a character value without the user having to press enter?

    Thank you for your help,
    Daniel
    Using standard functions, you cannot.
    Read: http://www.parashift.com/c++-faq-lit...html#faq-15.17
    However, if your compiler has conio.h you could use getch() or one of its equivalents.

  4. #4
    Registered User subdene's Avatar
    Join Date
    Jan 2002
    Posts
    367
    ooops missed that bit
    having to press enter
    sorry
    Be a leader and not a follower.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Another syntax error
    By caldeira in forum C Programming
    Replies: 31
    Last Post: 09-05-2008, 01:01 AM
  2. The Interactive Animation - my first released C program
    By ulillillia in forum A Brief History of Cprogramming.com
    Replies: 48
    Last Post: 05-10-2007, 02:25 AM
  3. lvalue error trying to copy between structures
    By emanresu in forum C Programming
    Replies: 2
    Last Post: 11-16-2006, 06:53 AM
  4. Obtaining source & destination IP,details of ICMP Header & each of field of it ???
    By cromologic in forum Networking/Device Communication
    Replies: 1
    Last Post: 04-29-2006, 02:49 PM
  5. Strings are V important...
    By NANO in forum C++ Programming
    Replies: 15
    Last Post: 04-14-2002, 11:57 AM