Wait for input..

This is a discussion on Wait for input.. within the C Programming forums, part of the General Programming Boards category; how do I wait for input for a text character or string? ie: main (int argc, char *argv[]) { while ...

  1. #1
    Registered User
    Join Date
    Oct 2002
    Posts
    48

    Wait for input..

    how do I wait for input for a text character or string?

    ie:

    main (int argc, char *argv[]) {


    while ( argv[0] != NULL) {
    printf("Enter Selection Please: "); // I want it to wait here for input
    if(argv[0] = "m") {

  2. #2
    Code Goddess Prelude's Avatar
    Join Date
    Sep 2001
    Posts
    9,796
    Just call an input function on stdin (getchar, for example).
    My best code is written with the delete key.

  3. #3
    Registered User
    Join Date
    Oct 2002
    Posts
    48
    That helps... But how do I get it to wait...
    Code:
    main (int argc, char *argv[]) {
    
    printf("Enter Selection Please: "); <-- WAIT HERE FOR INPUT...
    char x = getchar();
    
    if(x = "m") {
     do stuff;;
    }

  4. #4
    Code Goddess Prelude's Avatar
    Join Date
    Sep 2001
    Posts
    9,796
    >But how do I get it to wait...
    Unless you changed your shell to raw mode, asking for input should block. Maybe you should be more specific about what you mean by "wait", and how it's not presently waiting.
    My best code is written with the delete key.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Why wait cursor still turning on?
    By Opariti in forum Windows Programming
    Replies: 0
    Last Post: 05-22-2009, 02:28 AM
  2. Replies: 3
    Last Post: 10-15-2008, 09:24 AM
  3. Signals, fork(), wait() and exec()
    By DJTurboToJo in forum C Programming
    Replies: 7
    Last Post: 03-18-2008, 09:14 AM
  4. Boom, Headoshot!!
    By mrafcho001 in forum A Brief History of Cprogramming.com
    Replies: 50
    Last Post: 07-21-2005, 08:28 PM
  5. anybody with experience using the wait() function?
    By flawildcat in forum C Programming
    Replies: 7
    Last Post: 04-22-2002, 02:43 PM

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