How do you truncate a file?

Flying On A Canvas Wing jinx at milton.u.washington.edu
Tue May 7 08:17:15 AEST 1991


In article <f25g_zd at rpi.edu> fitz at mml0.meche.rpi.edu (Brian Fitzgerald) writes:
>Rudi Cilibrasi writes:
>>Suppose I have a 100-byte file called "myfile.dat", and I want to get
>>rid of the last 10 bytes.
>
>#include <stdio.h>
>main () {
>int	i;
>for (i=0; i < 90 ; i++) {
>		(void) putchar(getchar());

You know, I may be wrong, but it seems that fread and fwrite would be
a little faster... 

-- 
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!jinx at milton.u.washington.edu!!Disclaimer: OFS.*           !
!                            !!*Obligatory Fucking Smiley  !
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!



More information about the Comp.lang.c mailing list