change the size of a file
#include <unistd.h> int chsize( int filedes, long size );
The chsize() function changes the size of the file associated with filedes, by extending or truncating the file to the length specified by size. If the file needs to be extended, the file is padded with NULL ('\0') characters.
close(), creat(), errno, open()
#include <stdio.h> #include <unistd.h> #include <fcntl.h> #include <sys/stat.h> void main() { int filedes; filedes= open( "file", O_RDWR | O_CREAT, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP ); if( filedes!= -1 ) { if( chsize( filedes, 32 * 1024L ) != 0 ) { printf( "Error extending file\n" ); } close( filedes); } }
WATCOM
All (except Netware, DOS/PM)