我需要阅读Linux中的stdin,但我的程序只接收没有新行的消息。STDIN无需按ENTER键即可阅读
我尝试这样的代码,但不工作:
int main (void)
{
char p_char[48];
memset(p_char, 0, sizeof(p_char));
fcntl(STDIN_FILENO, F_SETFL, FNDELAY);
read(STDIN_FILENO, p_char, sizeof(p_char));
}
有人有一个建议?
这是你想要做的? http://stackoverflow.com/questions/421860/cc-capture-characters-from-standard-input-without-waiting-for-enter-to-be-pr – Mike 2013-03-07 17:47:51
refr to http://stackoverflow.com/questions/ 7469139/what-is-equivalent-to-getch-getche-in-linux – MOHAMED 2013-03-07 18:02:09