C Programming Problem

Mike Laman laman at ivory.SanDiego.NCR.COM
Thu Jan 5 09:16:41 AEST 1989


In article <32229 at auc.UUCP> tab at auc.UUCP (0-Terrence Brannon ) writes:
	:
	:
	:
>#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);
		^            ^
	 Change to ';'   Remove this ';'.  Now you will get 3 loop iterations.
	 Syntax error?! I guess you typed in this one for the message.

>	{
>	fscanf(fp, "%s %d %d %d %d %d %d", a, q, r, s, t, u, v);

	Change this fscanf() to:
	fscanf(fp, "%s %d %d %d %d %d %d", a, &q, &r, &s, &t, &u, &v);
				You must pass the data addresses to fscanf()
				so it can change your data variables!
				The "a" variable is the address of the area;
				that's why "a" was proprly initialized.
				Next time read the manual more carefully!

>	printf("%s %d %d %d %d %d %d", a, q, r, s, t, u, v);
>	}
>}

Mike Laman



More information about the Comp.lang.c mailing list