Mail Archives: djgpp/1997/03/23/01:15:21
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 -