Re: How to Truncate a file opened by fopen()

--- Harsha Kodnad <harsha km tallysolutions com> wrote:

> Hi All,
>     How can I truncate  a file opened by fopen() ?
>     If I want to extend my file or truncate my file I have to use ftruncate,
> but ftruncate takes int (file descriptor) is there any function which takes
> FILE * ?

 Note that fopen has a mode parameter , one of which is: (from man fopen)
 "w"     Truncate  file  to  zero length or create text file for writing. The
stream is positioned at the beginning of the file.

  In case you still need to get the file descriptor from a FILE* , you can use
 int fileno(FILE *stream);

  man fileno for more details.



Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 

[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]