Thread: stopping a program

  1. #1
    Unregistered
    Guest

    Question stopping a program

    i write a program and i want to stop it by pressind " CTRL-D" .(press only once);

    i also write a line thar stops the program but it stops it by pressing "CTRL-D"twice ,
    what should i do

  2. #2
    End Of Line Hammer's Avatar
    Join Date
    Apr 2002
    Posts
    6,231
    Can you expand on your question and provide a snippet of source please?

    What is the application doing when the user presses CTRL+D?

    Sorry, but I don't understand your second question at all.
    When all else fails, read the instructions.
    If you're posting code, use code tags: [code] /* insert code here */ [/code]

  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
    Code:
    char buff[BUFSIZ];
    while ( fgetc( buff, BUFSIZ, stdin ) != NULL ) {
      // do stuff
    }
    This should loop until you enter CTRL-D (once)

    > i also write a line thar stops the program but it stops it by pressing "CTRL-D"twice
    This can be because you have ununsed input

    For example
    ABCD\n
    CTRL-D

    Only needs you to press CTRL-D once

    Whereas
    ABCD CTRL-D
    CTRL-D

    Needs you to press CTRL-D twice

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 4
    Last Post: 02-21-2008, 10:39 AM
  2. Using variables in system()
    By Afro in forum C Programming
    Replies: 8
    Last Post: 07-03-2007, 12:27 PM
  3. BOOKKEEPING PROGRAM, need help!
    By yabud in forum C Programming
    Replies: 3
    Last Post: 11-16-2006, 11:17 PM
  4. My program, anyhelp
    By @licomb in forum C Programming
    Replies: 14
    Last Post: 08-14-2001, 10:04 PM