Isn't there a way to end a loop by inputing Ctrl-z using scanf and comparing the result to EOF?
Isn't there a way to end a loop by inputing Ctrl-z using scanf and comparing the result to EOF?
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.
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
Ctrl+C is also another option..
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.