How do you truncate a file?

Henry Spencer henry at zoo.toronto.edu
Sun May 5 15:20:08 AEST 1991


In article <1991May5.024348.4203 at csusac.csus.edu> cilibrar at athena.ecs.csus.edu (Rudi Cilibrasi) writes:
>Suppose I have a 100-byte file called "myfile.dat", and I want to get
>rid of the last 10 bytes...

ANSI C provides no way to truncate a file without reading and rewriting it.
In fact, there is no portable way; some systems can't do it.

If you wanted a system-specific way to do it, you should ask the question
in a suitable newsgroup, like comp.os.msdos.programmer or comp.unix.questions.
-- 
And the bean-counter replied,           | Henry Spencer @ U of Toronto Zoology
"beans are more important".             |  henry at zoo.toronto.edu  utzoo!henry



More information about the Comp.lang.c mailing list