Isn't there a way to end a loop by inputing Ctrl-z using scanf and comparing the result to EOF?
Printable View
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.
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.