[NEWBIE] Access violation and stack trace errors

From: Zenja Ivkovic (izenja@HOME.COM)
Date: 08/28/00


This is sort of off-topic (I'm trying to make a little program)
but I've been looking through the circle code and seen this sort of
thing work right in many places.

After opening a file for reading with fopen(), I have this:

p_debug("Reading data from file..");
fgets(buf, 80, fl);
if(sscanf(buf, "%d %d %d", balance, owe, due) != 3)
   f_error("Format error reading data from input file.");
sprintf(buf2, "Got %d for balance, %d for money owed, and %d for money due
for pay.", balance, owe, due);
p_debug(buf2);

It compiles fine but the error is in run-time.  The program outputs the
"Reading date from file.." part as my function tells it to, reads a line
from the file into 'buf', but when it tries to execute the sscanf() I get:

[*] Debug:  Reading data from file..
[main] C:\DJGPP\PROGRAMS\MONEY.EXE 1000 (0) handle_exceptions: Exception:
STATUS
_ACCESS_VIOLATION
[main] MONEY 1000 (0) handle_exceptions: Dumping stack trace to
MONEY.EXE.core

I think the problem is about it trying to access a part of the memory
which is protected, but I don't know how to fix it.  If anyone can give me
any help on what I need to do (I think I need to use pointers, but I've
tried that and don't understand how to use them very well), it would be
really appreciated.


     +------------------------------------------------------------+
     | Ensure that you have read the CircleMUD Mailing List FAQ:  |
     |  http://qsilver.queensu.ca/~fletchra/Circle/list-faq.html  |
     +------------------------------------------------------------+



This archive was generated by hypermail 2b30 : 04/11/01 PDT