Go to the first, previous, next, last section, table of contents.


ftruncate

Syntax

#include <unistd.h>

int ftruncate(int handle, off_t where);

Description

This function truncates the file open on handle at byte position where. The file pointer associated with handle is not changed.

Note that this function knows nothing about buffering by stdio functions like fwrite and fprintf, so if handle comes from a FILE object, you need to call fflush before calling this function.

Return Value

Zero for success, nonzero for failure.

Portability

not ANSI, not POSIX

Example

int x = open("data", O_WRONLY);
ftruncate(x, 1000);
close(x);


Go to the first, previous, next, last section, table of contents.