[comp.lang.c] MSC 5.1 file I/O bugs?

jvb7u@astsun.astro.Virginia.EDU (Jon V. Brinkmann) (05/04/90)

I have a strange problem with a pair of programs that appear to point to a
bug or bugs in MSC 5.1.  I'll detail each separately.

1.	Program A reads an ASCII file which is an array of real numbers.
	The first line contains the size of the array as two integers.
	The next two lines are comment lines and are discarded.  Each
	line is terminated by a <CR><LF> pair.  The program contains:

	FILE *fp;
	char buffer[BUFSIZ];
	int m, n;

	fgets (buffer, BUFSIZ, fp);
	sscanf (buffer, "%d %d", &m, &n);

	fgets (buffer, BUFSIZ, fp);
	fgets (buffer, BUFSIZ, fp);

	The bug manifests itself in that the second fgets gets the third line
	of the file!  I've also tried using scanf instead of the fgets/sscanf
	pair with the same result.

2.	I have a program in C to read GIF files from Marcel Mohl in Sweden.
	It uses getc and fread to read the binary data.  It reads the header
	information in the GIF file with fread and the compressed data with
	getc.  At some point, about 100 bytes into the data, a single getc
	call (confirmed using CodeView) reads the entire file at once and
	returns an EOF error!  The program itself is too long to post here,
	but I'll gladly mail it to anyone willing to take a stab at it!
	Oh yes, the reason I'm going to all this trouble, is that the display
	I'm using is a PCVision frame grabber, not a display adapter.

Jon

Jon Brinkmann					Astronomy Department
Internet:	jvb7u@Virginia.EDU		University of Virginia
UUCP:		...!uunet!virginia!jvb7u	P.O. Box 3818
SPAN/HEPnet:	6654::jvb7u			Charlottesville, VA 22903-0818