From: Damian Yerrick Newsgroups: comp.os.msdos.djgpp Subject: Re: reading text files Organization: Pin Eight Software http://pineight.8m.com/ Message-ID: References: X-Newsreader: Forte Agent 1.7/32.534 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Lines: 30 X-Trace: /ba9QcfNQIxLTijs8Gzul8nXfonOS2/7Rgshbb3WzEGf8N4yr8lCW+409jLexuZKrlCuji98StIp!3wrglIFN5ebmj/wUzJkkBzQemA3Ch1UckuDlp8O13oLtr/OuJom5ZqwlxHj4soyP4vIq/w8ziRVj!hsTZ X-Complaints-To: abuse AT gte DOT net X-Abuse-Info: Please be sure to forward a copy of ALL headers X-Abuse-Info: Otherwise we will be unable to process your complaint properly NNTP-Posting-Date: Tue, 02 May 2000 14:23:26 GMT Distribution: world Date: Tue, 02 May 2000 14:23:26 GMT To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Reply-To: djgpp AT delorie DOT com On Tue, 02 May 2000 05:30:49 +0000, "nimrod a. abing" wrote: [snipped most of source code] >> //here is the place to read in added and counted > >Hmmm... judging from your comments, you're using C++. Or C9x, which GCC partially supports. One of the new features of the C99 standard is single-line comments, something it borrowed from the C++ language. >Or have tried replacing `fread' with `fscanf'? It >works just like `scanf' only it works with *open* >files. `scanf("%d", %data)' is also >`fscanf(stdin, "%d", &data)'. `fread' is best used >for reading in large chunks of a file opened in >binary mode. In your case, `fscanf' would work since >your separators are newlines. scanf() and fscanf() introduce buffer overflow errors. I'd suggest fgets() with sscanf(). -- Damian Yerrick "I refuse to listen to those who refuse to listen to reason." See the whole sig: http://www.rose-hulman.edu/~yerricde/sig.html This is McAfee VirusScan. Add these two lines to your signature to prevent the spread of signature viruses. http://www.mcafee.com/