I am doing a terminal coding like Linux terminal with Linux terminal and I need to quit the program when the user press ctrl + D keyword But I do not know how the user has pressed these keywords, thanks for your help.
I am getting input with fgets ()
Ctrl + D The end-of-file is In that case, fgets ()
will return an empty pointer.
Then, the main loop of your program might be able to see something like this:
four buffers [2000]; Const char * input = fgets (buffer, size (buffer), staden); Whereas (input) {do_something_with (input); Input = fgets (buffer, size (buffer), staden); }
Note that this only works for simple buffer inputs. For information about low-level keyboard handling, see
No comments:
Post a Comment