Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!uunet!munnari.oz.au!yoyo.aarnet.edu.au!sirius.ucs.adelaide.edu.au!levels!marwk From: marwk@levels.sait.edu.au Newsgroups: comp.os.msdos.programmer Subject: Re: Turbo C and ^Z's Message-ID: <15800.27847903@levels.sait.edu.au> Date: 4 Jan 91 12:45:54 GMT References: Followup-To: comp.os.msdos.programmer Organization: Sth Australian Inst of Technology Lines: 19 In article , otto@tukki.jyu.fi (Otto J. Makela) writes: > In a fit of desperation, I wrote the following code to get rid of trailing > SUB's (^Z's, 0x1A) from MeSsy-DOS files, to make porting programs from Unix > easier... what am I doing wrong ? Or is it the compiler (I tried compiling > this with an ancient Turbo C 2.0) ? I've made similar code to work on Manx > Aztec C86 4.10d (a nice compiler, but sadly out of date). > -- > #include > #include The method is to use the method of handles instead of streams. Use open (in binary mode), read, write, close. Read the reference manual on these. You could use flen = filelength(input handle) and read all of the data into a buffer but then you must be certain in advance that the last byte is the EOF marker (1A) and not data. Ray