Thread: End a loop using Ctrl-z

  1. #1
    Registered User
    Join Date
    Sep 2009
    Posts
    7

    End a loop using Ctrl-z

    Isn't there a way to end a loop by inputing Ctrl-z using scanf and comparing the result to EOF?

  2. #2
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,336
    Yes. You input Ctrl-Z (it has to be on a line by itself) and compare the result (of scanf, not the value loaded into the variable) to EOF.

  3. #3
    and the hat of sweating
    Join Date
    Aug 2007
    Location
    Toronto, ON
    Posts
    3,545
    Well it depends on the platform you're using.
    If you're running on Windows, then Ctrl-z should work; if you're on UNIX, then you need Ctrl-d.
    "I am probably the laziest programmer on the planet, a fact with which anyone who has ever seen my code will agree." - esbo, 11/15/2008

    "the internet is a scary place to be thats why i dont use it much." - billet, 03/17/2010

  4. #4
    Registered User
    Join Date
    Sep 2009
    Location
    USA
    Posts
    63
    Ctrl+C is also another option..

  5. #5
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    No it isn't. ctrl+c effectively kills the program in most shells. You want ctrl+d or ctrl+c.


    Quzah.
    Hope is the first step on the road to disappointment.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Data Structure Eror
    By prominababy in forum C Programming
    Replies: 3
    Last Post: 01-06-2009, 09:35 AM
  2. Dikumud
    By maxorator in forum C++ Programming
    Replies: 1
    Last Post: 10-01-2005, 06:39 AM
  3. Possible circular definition with singleton objects
    By techrolla in forum C++ Programming
    Replies: 3
    Last Post: 12-26-2004, 10:46 AM
  4. Reading an array in a while not end of file loop
    By npg316 in forum C Programming
    Replies: 5
    Last Post: 10-18-2004, 12:25 PM
  5. End of Code Loop Question
    By JuanSverige in forum C++ Programming
    Replies: 1
    Last Post: 04-08-2003, 10:35 AM