Trouble spot!

John Gordon gordon at osiris.cso.uiuc.edu
Fri Apr 12 11:27:18 AEST 1991


	I noticed several things about the program:

	1) When you are fscanf()'ing in the data, you need to put a & by
the integer you were reading in.  Scanf() and related functions ALWAYS
require a & before the recieving variable when reading in a single
int, float, or char.  Not for an array, though.

example: scanf("%d", &answer);

	2) You are putting the data in the file with an fwrite(), but you
are reading it in with scanf().  You really should do input and output
the same way.  I would suggest reading it in with an fread().

	3) Don't use a * with fclose.  when you say

	FILE *fp;

	close that file with

	fclose(fp);

	and don't put a * in front of it.


---
John Gordon
Internet: gordon at osiris.cso.uiuc.edu        #include <disclaimer.h>
          gordon at cerl.cecer.army.mil       #include <clever_saying.h>



More information about the Comp.lang.c mailing list