read() from stdin doesn't ignore newline

前端 未结 5 874
情话喂你
情话喂你 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:18

    I'm quite positive there's no way to do it without examining the buffer contents. Even readline() does just that. Why are you opposed to it, anyways?

提交回复
热议问题