Two questions about the standard library

Ian Lance Taylor ian at airs.UUCP
Tue Mar 19 11:04:56 AEST 1991


I have two questions about the ANSI C standard library.  These are
problems I have encountered when implementing my own standard library.
I apologize if they have been answered before.

1) The size of the buffer argument to the fgets function is passed as
an int.  Why not use size_t?  Given that it is int, how should fgets
behave if the buffer size is negative (or, for that matter, zero)?  If
this is not regarded as an error, should it set the first byte of the
buffer to zero or not?

2) When using %g with no precision in the printf family of functions,
what precision is assumed?  The standard says that a zero precision is
taken as one, but does not appear to specify the action taken for a
missing precision.  I would assume that a missing precision should be
taken as 1, but that differs from %e and %f, in which a missing
precision is taken as 6.  What is correct?

It may be that the standard does not specify what to do in these
cases, in which case I would like to know what the common practice is.

Thanks.
-- 
Ian Taylor               airs!ian at uunet.uu.net                uunet!airs!ian
Quoted from a courtroom deposition in the Boston Globe of February 18, 1991:
Q: Doctor, how many autopsies have you performed on dead people?
A: All my autopsies have been on dead people.



More information about the Comp.std.c mailing list