How do you truncate a file?
dan debrunner
djd at sirdan.sybase.com
Fri May 10 08:23:18 AEST 1991
In article <1991May6.194614.9641 at pensoft.uucp> lwb at pensoft.uucp (Lance Bledsoe) writes:
>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());
>
>Do you think you could have thought of a *slower* way to do this???
Actually a correct way would have been even better. Remember putchar()
is a macro on many platforms which evaluates its argument twice.
Dan.
More information about the Comp.lang.c
mailing list