Mail Archives: djgpp/1999/06/30/10:26:49
David Mitchell <dmitchell AT inet DOT net DOT nz> wrote:
> Could somebody tell me what is wrong with this code?
> int points;
> FILE *objFile;
> objFile = fopen(fname, "rt");
> fscanf(objFile, "%d", points);
> When I run this, my program crashes with this message:
You might try compile with -g and then use symify a.exe with the
traceback on the screen to identify the line where your program
crashes. (read the FAQ on this subject)
Furthermore fscanf needs a pointer to where it should put the
variable:
fscanf(objFile, "%d", &points);
and a if (objFile==NULL) return; after the fopen would be a good idea,
so you know when the file did not open correctly.
hth,
Robert
- Raw text -