Path: utzoo!utgpu!news-server.csri.toronto.edu!mailrus!cs.utexas.edu!samsung!sdd.hp.com!decwrl!ucbvax!pasteur!sim.berkeley.edu!johnm From: johnm@sim.berkeley.edu (John D. Mitchell) Newsgroups: comp.lang.c Subject: Re: TurboC fgets() bug?? Keywords: TurboC msdos fgets Message-ID: <26071@pasteur.Berkeley.EDU> Date: 11 Jul 90 05:09:31 GMT Sender: news@pasteur.Berkeley.EDU Reply-To: johnm@sim.berkeley.edu (John D. Mitchell) Followup-To: alt.msdos.programmer Organization: University of California, Berkeley Lines: 30 John Core at home, Harrisburg,PA writes: > while using fgets with turbo C on Ms-dos I get the following problem: ] when reading a char *str with fgets the manual says that ] fgets will stop at num-1 characters or if a read character ] is a newline. ] ] char *fgets(str,num,stream) ] ] I have never had problems with fgets on Unix SYSV but under ] TURBOC ON THE SAME FILE fgets does not always find the ] newline marker, the operation is at times unpredictable. ] since it seems to miss the newline char it the continues to ] read the following lines in the file untill the num-1 is ] satisfied. ] ]Has anyone else had experience with this problem. If you can help or ]al least tell me I am doing something wrong, or that it is a bug >Thanks in advance I don't know for sure but I've had similar problems that were NOT caused by the *input* routine (i.e. fgets()). The problem was caused by having the file end only with a EOF instead of an EOLN,EOF pair. In english (I hope) the last line of the file was NOT ended with a CR/LF just an EOF. Good Luck, John Mitchell johnm@sim.Berkeley.EDU #include