delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1999/06/30/10:26:49

From: Boon van der RJ <rjvdboon AT cs DOT vu DOT nl>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: Files with GCC
Date: Wed, 30 Jun 1999 13:45:37 GMT
Organization: Fac. Wiskunde & Informatica, VU, Amsterdam
Lines: 20
Message-ID: <7ld721$k9n@cs.vu.nl>
References: <930735428 DOT 887115 AT kyle DOT inet DOT net DOT nz>
NNTP-Posting-Host: galjas.cs.vu.nl
User-Agent: tin/pre-1.4-19990413 ("Endemoniada") (UNIX) (SunOS/5.5.1 (sun4u))
X-Poster-Key: sha1:04QELtbs0cEdmYB9BSNp/CeKM1k=
Cancel-Lock: sha1:jvIxxM7moLHyduLqPCC6uKyGKjQ=
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

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 -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019