delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/03/23/01:15:21

From: mert0407 AT sable DOT ox DOT ac DOT uk (George Foot)
Newsgroups: comp.os.msdos.djgpp
Subject: Re: strange problem
Date: Sat, 22 Mar 1997 23:28:10 GMT
Organization: Oxford University
Lines: 28
Message-ID: <333469fc.1923857@news.easynet.co.uk>
References: <33332701 DOT 1A29 AT uit DOT net>
NNTP-Posting-Host: foot.easynet.co.uk
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

On Fri, 21 Mar 1997 18:25:37 -0600, Chris Larson <clarson AT uit DOT net>
wrote:

>I'm having a strange problem with DJGPP(most likely my error).  I am
>reading integer and floating point values into a structure from a text
>file.  If I print the variables to the screen while still in the while()
>loop that reads them in (using fscanf()and fseek()) the values print out
>right, but if I print them out after exiting the while() loop they don't
>retain there value(usually = 0). It also does not always work at all but
>will bomb out with the following message. 
>
>Exiting due to signal SIGSEGV
...

This may sound like a simple answer, but make sure you're passing
fscanf the *address* of the variables to put the values in; it could
easily cause the unreliable behaviour and SIGSEGV if you don't do
this. Generally, prefix the variable name with a `&'. If you're not
sure, post the fscanf line(s) from your source code and possibly a
copy of the struct you're using too.

Also, make sure the struct you're trying to use still exists after the
while loop; if it is allocated on the fly within the while loop its
scope may be limited to that block; I'm not too sure though, and I
would expect the compiler to warn you about this or give an error.

-- 
George Foot

- Raw text -


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