Re: cutting file by fwrite() EOF ?

From: Måns Rullgård (mru_at_mru.ath.cx)
Date: 09/28/04


Date: Tue, 28 Sep 2004 13:59:51 +0200

vertigo <ax178@wp.pl> writes:

> Hello
> I wanted to cut file, so i:
>
> int *data=(int*)malloc(sizeof(int));
> data[0]=EOF;
> fseek(file,new_size,SEEK_SET);
> fwrite((void*)data,sizeof(int),1,file);
>
> but this does not work. Why ? How can i cut file ?

man truncate
man ftruncate

-- 
Måns Rullgård
mru@mru.ath.cx


Relevant Pages

  • [PATCH] ftruncate does not always update m/ctime
    ... not quite being handled correctly for ftruncate() calls. ... openshall mark for update the st_ctime ... Upon successful completion, if the file size is changed, this ... the ftruncate case was being handled like the truncate case. ...
    (Linux-Kernel)
  • Re: create a file
    ... man 2 creat ... man 2 truncate ... man 2 ftruncate ... John ...
    (comp.unix.programmer)
  • Re: Create File of Size X
    ... Is a simple loop the best way? ... ftruncate(), or truncateif you don't need the file open. ... Alex ...
    (comp.unix.programmer)
  • Re: Modifiying End-Of-File
    ... I said incorrectly that the 'truncate' ... function zeroes out the data. ... 'ftruncate' perform exacly as expected (when reducing the ...
    (comp.os.linux.misc)