🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: comp.sys.next.programmer
1 messages
1 total messages Started by Eskandar Ensafi Mon, 06 Apr 1992 22:57
C function "sscanf" generates: Memory access exception (protection failure)
#553
Author: Eskandar Ensafi
Date: Mon, 06 Apr 1992 22:57
50 lines
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
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads