Path: utzoo!attcan!telly!druid!darcy From: darcy@druid.uucp (D'Arcy J.M. Cain) Newsgroups: comp.lang.c Subject: Re: Turbo C, fopen(), fprintf() and ^Z - I need help!! Message-ID: <1990Sep20.014132.29461@druid.uucp> Date: 20 Sep 90 01:41:32 GMT References: <38742@ucbvax.BERKELEY.EDU> <14084@mentor.cc.purdue.edu> Organization: D'Arcy Cain Consulting, West Hill, Ontario Lines: 31 In article <14084@mentor.cc.purdue.edu> edgincd2@mentor.cc.purdue.edu (Chris Edgington *Computer Science Major*) writes: >In article <38742@ucbvax.BERKELEY.EDU>, brand@janus.Berkeley.EDU (Graham Brand) writes: >> instruction. The problem that I am having is that the line that is >> appended in the file is preceeded with a ^Z which makes the data >> invisible when a type command is issued from MSDOS. I can use vi and > >Is the ^Z leftover from the original dos file or is it the first character of >the append data?? If it is leftover from the original file, you could you >fsetpos to set the position for writing as eof(original)-1, then it would >erase the ^Z > But don't open the file in append mode. It repositions the file pointer to the end of the file before each write. Also you might want to check to see if the last character is a ^Z as well as the ones before the last. Some of those old programs use the CP/M method of filling a buffer with ^Zs before writing to it so you could have as many as 128 of them. This might work: long pos = 0; ... do { fseek(fp, --pos, SEEK_END) } while ((c = fgetc(fp)) == 0x1a); fseek(fp, ++pos, SEEK_END); That leaves the file pointing to the first of any ^Zs or the end of file if there are none. -- D'Arcy J.M. Cain (darcy@druid) | D'Arcy Cain Consulting | MS-DOS: The Andrew Dice Clay West Hill, Ontario, Canada | of operating systems. + 416 281 6094 |