puts() return value - Watcom 10.6

According to the manual: “The puts() function returns a non-zero value
if an error occurs; otherwise it returns a zero. When an error has
occurred, errno contains a value that indicates the type of error that
has been detected.”

If I have:

if (puts(“Some text.”) != 0){
perror(“Oops:”);
}

I always get:

Some text.
Oops: No error

Am I doing something wrong or is the documentation wrong? If the later,
what are the correct return values?


Bob Harris In short, you may buy a servant or slave,
Bath, NH but you cannot buy a friend.
bob@microprograms.com (Thoreau: Wild Fruits)

Robert L. Harris <bob@microprograms.com> wrote:
: According to the manual: “The puts() function returns a non-zero value
: if an error occurs; otherwise it returns a zero. When an error has
: occurred, errno contains a value that indicates the type of error that
: has been detected.”

You have old docs. They now read:

Returns:
A nonnegative value (which is the number of characters read, including
newlines), or EOF if an error occurs. When an error has occurred,
errno indicates the type of error detected.


Steve Reid stever@qnx.com
TechPubs (Technical Publications)
QNX Software Systems Ltd.

Steve Reid <stever@qnx.com> wrote:

Robert L. Harris <> bob@microprograms.com> > wrote:
: According to the manual: “The puts() function returns a non-zero value
: if an error occurs; otherwise it returns a zero. When an error has
: occurred, errno contains a value that indicates the type of error that
: has been detected.”

You have old docs. They now read:

Returns:
A nonnegative value (which is the number of characters read, including
newlines), or EOF if an error occurs. When an error has occurred,
errno indicates the type of error detected.

Is that always zero? puts() doesn’t read any characters… :slight_smile:


Wojtek Lerch (wojtek@qnx.com) QNX Software Systems Ltd.