I have an application that implements an interactive shell, similar to how the Python console / irb works. The problem now is that if the user accidentally hits ^D
EOF is issued and my getline()
call returns an empty string which i treat as "no input" and display the prompt again.
This then results in an endless loop that prints the prompt.
Now in Python I would solve that problem by catching EOFError
, but in C++ no exception is raised I could catch and there doesn't seem to be a setting on cin
to ignore EOF.
Any hints?