www.delorie.com/djgpp/doc/libc/libc_368.html   search  
libc.a reference

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

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.

ftruncate does not support directories.

Return Value

Zero for success, nonzero for failure.

Portability

ANSI/ISO C No
POSIX No

Example

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


  webmaster   donations   bookstore     delorie software   privacy  
  Copyright 2004   by DJ Delorie     Updated Apr 2004