Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 5840983
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T11:49:43+00:00 2026-05-22T11:49:43+00:00

test.h ——- struct session { int a; int c; int b; }; struct session*

  • 0
test.h
-------
struct session {
    int a;
    int c;
    int b;
};
struct session* pEvent;
#import <Foundation/Foundation.h>


@interface test : NSObject {

}
-(void)set;
@end

test.m
--------

#import "test.h"


@implementation test

-(id)init{
    pEvent->a=10;
    pEvent->c='a';
    pEvent->b=20;
    return self;
}
-(void)set{

    //struct session* pEvent;
    //pEvent->a=10;
    //pEvent->c='a';
    //pEvent->b=20;
    NSLog(@"a:%d c:%c b:%d",pEvent->a,pEvent->c,pEvent->b);

}

@end

I am getting EXC_BAD_ACCESS runtime exception and the debugger points to pEvent->a when

declared in both the ways inside the init method or inside the set method.

Do i need to intialise the structure as pEvent = new session;? If declared like this I’m

getting new undeclared error. Then I tried with pEvent = [session new]; and pEvent = [[session alloc]init]; If declared like this i’m getting session undeclared error.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T11:49:44+00:00Added an answer on May 22, 2026 at 11:49 am

    Try this:

    struct session {
        int a;
        int c;
        int b;
    } pEventStruct;
    struct session* pEvent = &pEventStruct;
    

    You got bad access as you have not allocated memory for pEvent, just declared a pointer.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

test.mxml: <?xml version=1.0 encoding=utf-8?> <mx:Application xmlns:mx=http://www.adobe.com/2006/mxml creationComplete=init() x=0 y=0 width=703 height=609 xmlns:ns1=* > <mx:Script>
test.h NSString *name; @property(nonatomic,retain) NSString *name; test.m @synthesize name; here why did we use
test image here: http://images.plurk.com/tn_4134189_bf54fe8e270ce41240d534b5133884ee.gif I've tried several solutions found on the internet but there
test.html <html> <!-- Please see the full php-ajax tutorial at http://www.php-learn-it.com/tutorials/starting_with_php_and_ajax.html If you found
Test case: <!DOCTYPE html> <html> <head> <meta charset=UTF-8 /> <script type=text/javascript src=/cufon.js></script> <script type=text/javascript
Test question via API key
Test cases for manual testing. Step by step procedure to test this functionality(sticky note)
# test-> a.pl my $file = '/home/joe/test'; if ( -f $file && -l $file
Test.xml: <?xml version=1.0 encoding=UTF-8?> <node>line1 line2 line3</node> CF code: <cfset xmlfile = ExpandPath(test.xml)> <cffile
test.php includes this: echo json_encode( array( array(name=>John,time=>2pm), array(name=>2,time=>1242pm), array(name=>J231ohn,time=>2p213m), )); jQuery : $.get(test.php, function(data)

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.