Skip to content
Search

C:fgets

lastmod 2020-03-22created 2020-03-221 edits

STDIN and PIPE

When you need to support both standard input (STDIN) and input passed through a PIPE at the same time, use 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

author Zer0 sitemap