read() from stdin doesn't ignore newline

前端 未结 5 842
情话喂你
情话喂你 2020-12-10 21:01

I am using the following conditional statement to read from standard input.

if ((n = read(0,buf,sizeof(buf))) != 0)

When inputting data fro

5条回答
  •  天涯浪人
    2020-12-10 21:04

    just type >1 instead of !=0

    the only false positives are single character responses followed by an interrupt (EOF)

提交回复
热议问题