don@trsvax.UUCP (05/22/91)
>Suppose I have a 100-byte file called "myfile.dat", and I want to get >rid of the last 10 bytes. The only way that I can figure out how to do >this is with something like the following: >main() >{ > char buf[100]; > FILE *fp; > fp = fopen("myfile.dat", "r"); > fread(buf, 1, 100, fp); > fclose(fp); > fp = fopen("myfile.dat", "w"); > fwrite(buf, 1, 90, fp); > fclose(fp); >} This does not necessarily truncate files in all operating systems. To correctly truncate the file using ANSI calls, add the line remove("myfile.dat"); after the first call to fclose(). --------------------------------------------------------------------------- I wouldn't bring up Paris if I were you. It's poor salesmanship. -- Casablanca Don Subt The opinions expressed above are Tandy Corp. strictly mine, not my employer's. 817-390-2923 don%trsvax@rwsys.lonestar.org