Hi,I,m writing puts()function and I want to know that I which situations it returns EOF
I know that when there is an error it return EOF but whad does it mean.
can you give me an example?

Recommended Answers

All 2 Replies

If there's a write error to the destination stream, you'll get a return value of EOF. Typically this means something along the lines of the target device no longer being available or getting corrupted. However, since puts writes to stdout, this is rather unlikely unless you've redirected stdout to a volatile location.

When this happens, the function should also set errno to a known value to indicate the error that occurred.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.