Truncate a file
#include <unistd.h> int ftruncate( int fildes, off_t length ); int ftruncate64( int fildes, off64_t length );
Use the -l c option to qcc to link against this library. This library is usually included automatically.
These functions cause the file referenced by fildes to have a size of length bytes. If the size of the file previously exceeded length, the extra data is discarded (this is similar to using the F_FREESP option with fcntl()). If the size of the file was previously shorter than length, the file size is extended with NUL characters (similar to the F_ALLOCSP option to fcntl()).
The value of the seek pointer isn't modified by a call to ftruncate().
Upon successful completion, the ftruncate() function marks the st_ctime and st_mtime fields of the file for update. If the ftruncate() function is unsuccessful, the file is unaffected.
Zero for success, or -1 if an error occurred (errno is set).
ftruncate() is POSIX 1003.1; ftruncate64() is Large-file support
mmap(), open(), shm_open(), truncate()