From: degiorgi AT inf DOT ethz DOT ch (Daniele Degiorgi) Newsgroups: comp.os.msdos.djgpp Subject: Re: ftell does'nt work properly Date: 21 Oct 1996 15:35:59 GMT Organization: Dept. Informatik, Swiss Federal Institute of Technology Lines: 29 Message-ID: <54g58v$gm1@neptune.ethz.ch> References: Reply-To: degiorgi AT inf DOT ethz DOT ch NNTP-Posting-Host: fido.inf.ethz.ch To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Some times ago I had the same problem: Developping a small compiler I used a big file as a source library. When I encountered an include statement within a module, I used to save the actual position with ftell(), reading the included module and at the end of this I used fseek to resume reading at the proper place. I had a first problem with a module in the library containing a single cr (0x0D). This seems to disturb all compilers I used (Borland C++, Visual C++ and djgpp). After fixing it (replacing it by blank in the file) all worked good with Borland C++ and Visual C++, but I still had problems with djgpp. The final solution was to use different FILE variables reopening the library file for each include and avoiding pairing of ftell/fseek. The troubles caused by the presence of the character 0x0D are dued to the fact that the ftell routine counts the presence of single chars and not pairs of cr/lf. But, as the different documentations warns about malfunctioning in case of presence of nonprintable characters in text files, this may be ok. In each case now I always try to avoid the usage of ftell/fseek in conjunction with DOS text files. Daniel