我正在尝试编写一个程序,在按ctrl + c后输出标准错误消息。我已经尝试使用
ctrl + c
if (cin.eof()) { std::cerr << "Message" << endl; }
但是没有打印任何标准错误。有其他方法吗?
Ctrl-c终止程序。查看https://www.tutorialspoint.com/how-do-i-catch-a-ctrlplusc-event-in-cplusplus的操作方法。