Subject: Re: fgets prototype bug?
To: Simon Burge <email@example.com>
From: Johan Danielsson <firstname.lastname@example.org>
Date: 11/16/1999 09:00:57
Simon Burge <email@example.com> writes:
> Is is a bug that fgets() takes an "int" as the size of the object
> and not a size_t?
Yes, but we can't do much about it, since it's defined that way in
`ANSI C', and C9x. C doesn't have an ssize_t type.
You *could* have different prototypes if _ANSI_C_SOURCE (or something)
is defined, but I really hate such solutions.
220.127.116.11 The fgets function
char *fgets(char * restrict s, int n,
FILE * restrict stream);
The fgets function reads at most one less than the number of
characters specified by n from the stream pointed to by stream into
the array pointed to by s. No additional characters are read after
a new-line character (which is retained) or after end-of-file. A
null character is written immediately after the last character read
into the array.
The fgets function returns s if successful. If end-of-file is
encountered and no characters have been read into the array, the
contents of the array remain unchanged and a null pointer is
returned. If a read error occurs during the operation, the array
contents are indeterminate and a null pointer is returned.