C Programming Problem

Terrence Brannon tab at auc.UUCP
Wed Jan 4 01:32:03 AEST 1989


Ok, this is my source:
---------------------

#include <stdio.h>

main()
{
	FILE	*fp;
	char	*a;
	int 	i, q, r, s, t, u, v;
		

	fp = fopen("tab.dat", "r");
	a = (char *) calloc (80, sizeof(char));

	for (i=0, i < 3; ++i);
	{
	fscanf(fp, "%s %d %d %d %d %d %d", a, q, r, s, t, u, v);
	printf("%s %d %d %d %d %d %d", a, q, r, s, t, u, v);
	}
}

And this is tab.dat:
-------------------	

I 11 16 88 22 20 10
O 11 16 88 22 23 21
I 11 16 88 22 23 30
O 11 16 88 22 23 39

When I do the following:
-----------------------
cc -g filename.c
sdb
r

I get a "doscan.c no such file or directory" error from sdb

This snippet of code works when i read character values from the 
file (ie: fscanf(fp, "%s %s %s %s %s %s %s", c1, c2, c3, c4, c5 ,c6, c7)
but if doesnt work when trying to read integer values from the file as
with the above fscanf in the source code.

Any ideas why valid integers from a file can't be read in as integers but
only can be read in a char strings?

...!gatech!auc!tab



More information about the Comp.lang.c mailing list