Skip to content

C:fgets

STDIN and PIPE

표준입력(STDIN)과 PIPE로 전달되는 입력을 동시에 호환시켜야 할 경우 fgets를 사용하면 된다.

The point is: When you press CTRL+D, you signal EOF on stdin of the parent. So the parent leaves this loop

while(fgets(buffer1,sizeof(buffer1),stdin) != NULL)

since fgets() returns NULL on EOF.

See also