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 7945691
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T00:56:40+00:00 2026-06-04T00:56:40+00:00

These are my two structs: struct upset { int location; int trigger; int type;

  • 0

These are my two structs:

struct upset {
  int location;     
  int trigger;    
  int type;      
  char bits[8]; 
  }; 

struct event {
  int category;
  int spill;
  int num_clock_ups;
  int num_data_ups;
  struct upset clock_ups[512];
  struct upset data_ups[512];
  };

but when i try to declare an array of struct events further down with this:

int nevents = 1755;
struct event total_events[nevents];

i get a segfault the first time i try to access anything in the array, upon checking with gdb, just before the segfault sizeof(total_events) is 0 and the difference in locations of total_events[1] and total_events[2] is 0x10, so it seems the arrays of struct upsets are not getting intialized or something.

what did i do wrong in initializing this array? are my structs set up poorly? i am very new at structs in C and in general.

  • 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-06-04T00:56:42+00:00Added an answer on June 4, 2026 at 12:56 am

    Is your process stack space big enough? By my calculation that array is going to take up at least (ignoring potential structure member alignment padding):

    [2*(13*512) + 4]*1755 = 22.3 MB
    

    of space. If total_events is a local variable, it’ll be allocated on the stack. Do you have that much stack space?

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

Sidebar

Related Questions

Considering these two structs: struct point { int x,y; }; struct pinfo { struct
Do these two structs have the same memory layout? (C++) struct A { int
I have these two structures... typedef struct{ MY_SECOND_STRUCT s1; }MY_FIRST_STRUCT; typedef struct{ int s1;
Suppose we have two structs: typedef struct Struct1 { short a_short; int id; }
I have two structs: // ----- non-const ----- struct arg_adapter { EArgType type; //
Take these two classes for instance: struct Owned { Owned() : i() { }
Do these two statements pass the same type of argument (a Hash) to the
I have two structs: template <typename T> struct Odp { T m_t; T operator=(const
What is the standard way to copy two structs that contain char arrays? Here
Consider these two structures: struct Task { public Int32 Id; public String Name; public

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.