Newsgroups: comp.lang.c
Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!fitz
From: fitz@mml0.meche.rpi.edu (Brian Fitzgerald)
Subject: Re: How do you truncate a file?
Message-ID: <f25g_zd@rpi.edu>
Nntp-Posting-Host: mml0.meche.rpi.edu
Organization: Rensselaer Polytechnic Institute, Troy NY
References: <1991May5.024348.4203@csusac.csus.edu>
Distribution: usa
Date: 5 May 91 17:35:30 GMT
Lines: 19

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());
	}
}

It has worked for me in the past.

Use the program with shell i/o redirection, as in

program < myfile.dat > truncated.dat

Brian
