Path: utzoo!utgpu!news-server.csri.toronto.edu!rutgers!gatech!purdue!news.cs.indiana.edu!sdd.hp.com!think.com!rpi!fitz From: fitz@mml0.meche.rpi.edu (Brian Fitzgerald) Newsgroups: comp.lang.c Subject: Re: How do you truncate a file? Message-ID: Date: 8 May 91 04:13:45 GMT References: <1991May6.194614.9641@pensoft.uucp> Distribution: usa Organization: Rensselaer Polytechnic Institute, Troy NY Lines: 25 Lance Bledsoe writes: >In article fitz@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 >>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??? Since the original poster's program uses fread and fwrite, it will run much faster than mine does, especially if his fread and fwrite call a decent assembler implementation of bcopy. The speed point is well taken, but neither the buffered I/O functions nor the character macros help Rudi, who would like to truncate his file in place without reading it into memory or using a temporary file. He's not running unix, and I think he's looking elsewhere for help now. Brian