Article View: comp.sys.next.programmer
Article #553C function "sscanf" generates: Memory access exception (protection failure)
From: Eskandar Ensafi
Date: Mon, 06 Apr 1992 22:57
Date: Mon, 06 Apr 1992 22:57
50 lines
1993 bytes
1993 bytes
Hi,
I am experiencing problems with the following piece of code which involves
using "sscanf" to read values from an app's defaults registration table:
----------------------------------------------------------------------------
#import <stdio.h>
#import <defaults.h>
- init
{
NXDefaultsVector windowDefaults =
{ {"windowFrame", "300 350 500 400"}, {NULL} };
NXRegisterDefaults( "MyApp", windowDefaults);
return self;
}
- myMethod
{
NXRect frame;
const char *defaultFrame;
defaultFrame = NXGetDefaultValue( "MyApp", "windowFrame");
sscanf( defaultFrame, "%f %f %f %f", &frame.origin.x, &frame.origin.y,
&frame.size.width, &frame.size.height);
/* Note: The problem is not associated with using "&frame.size.width" and
other similar arguments. The same error occurs with "float" variables */
return self;
}
----------------------------------------------------------------------------
The problem seems to arise in here, but the compiler says that the error
happens in function "fgets", but I haven't used a function "fgets" so it must
be asscoaited with how "sscanf" and/or "NXGetDEfaultValue" work. GDB gives me
the follwing message:
>
Program generated(1): Memory access exception on address 0x5006a14 (protection
failure).
0x501684e in fgets ()
>
Thanks in advance!
Eskandar.
esky@mayhem.icsl.ucla.edu
esky@marathon.cs.ucla.edu
Technical Details
Message-ID:
<1992Apr6.225735.3879@cs.ucla.edu>Path:
arc1-ca.pugleaf.net!sparky!uunet!elroy.jpl.nasa.gov!ucla-cs!usenetShow Full Headers
Complete Article Headers
Newsgroups: comp.sys.next.programmer Path: arc1-ca.pugleaf.net!sparky!uunet!elroy.jpl.nasa.gov!ucla-cs!usenet From: esky@marathon.cs.ucla.edu (Eskandar Ensafi) Subject: C function "sscanf" generates: Memory access exception (protection failure) Message-ID: <1992Apr6.225735.3879@cs.ucla.edu> Keywords: sscanf defaults problem memory Sender: usenet@cs.ucla.edu (Mr Usenet) Nntp-Posting-Host: marathon.cs.ucla.edu Reply-To: esky@marathon.cs.ucla.edu Organization: UCLA, Computer Science Department Date: Mon, 6 Apr 92 22:57:35 GMT