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

  • SEARCH
  • Home
  • 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.c int main () { void a; return 0; } I use gcc to
struct Test { int var; char *arr; } int main() { Test a; a.arr
test.c: int main() { return 0; } I haven't used any flags (I am
Given test.txt containing: test message I want to end up with: testing a message
test.py def add(a,b): print a,b,a+b return a+b c program #include <python.h> int _tmain(int argc,
test.c(6) : warning C4013: 'add' undefined; assuming extern returning int I've encountered many times
#test/factories.rb Factory.define :estado do |estado| estado.nombre Distrito Federal end Factory.define :municipio do |municipio| municipio.nombre
test::Int->(Int-> Char)->Char test n f = f(n) DD::Int->Char DD a | a==1 = '1'
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>
class Test { void m1(byte b) { System.out.print(byte); } void m1(short s) { System.out.print(short);

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.