Public Comment Number PC-UK0091 ISO/IEC CD 9899 (SC22N2620) Public Comment =========================================== Date: 1998-02-25 Author: N.M Maclaren Author Affiliation: Self Postal Address: University of Cambridge, Computer Laboratory, New Museums Site, Pembroke Street, Cambridge CB3 3QG, United Kingdom E-mail Address: Telephone Number: +44 1223 334761 Fax Number: +44 1223 334679 Number of individual comments: 1 Comment 1. Category: Feature that should be included Committee Draft subsection: 7.13.5 Title: Truncating a file Detailed description: A frequently missed feature of C is the ability to truncate a file; all that the standard provides is the ability to clear a file and rewrite it from the beginning. The following specification deliberately does not attempt to follow any common existing practice, but is worded so that it should be easy to implement on most important systems and requires a near-minimal specification (so as to maintain consistency with other parts of the standard.) I have implemented something very close to the following specification on both MVS and Unix. I suggest adding something like the following: 7.13.5.8 The ftruncate function Synopsis 1 #include int ftruncate(FILE *stream) Description 2 The ftruncate function truncates the file at the current position. All characters in the file beyond the current position become inaccessible, and the logical end of file is set to the current position. All other properties of the file and stream are unchanged, unless an error occurs. 3 A call to the ftruncate function is an output operation (7.13.5.3). Returns 4 The ftruncate function returns zero if the file was successfully truncated, or EOF if the stream was open for reading or any other errors were detected.