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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T17:20:16+00:00 2026-05-26T17:20:16+00:00

I have two structures : struct bets{ int bets[36]; int last_bet; }bets struct board{

  • 0

I have two structures :

struct bets{
   int bets[36];
   int last_bet;
}bets
struct board{
   int type;
   bets *bet;
 }board

I created a chunk of shad memory of sizeof(board). So, I got a pointer to the Board in shared memory (lest call it ptr).
I did created a new board and bets structure,
board *b, bets * bts, …. added board->bet = bts.
Now, I copied the “b” to ptr
memcpy(ptr, bts, sizeof(board)).
I can access the ptr->type.
But when I try to access
ptr->bet->last_bet, I get a segmentation-fault error.

I also tried copying like this:

board *b;
memcpy(ptr, b, sizeof(board));
bets *bts;
memcpy(ptr->bet, bts, sizeof(bets)).

Still getting segmentation-fault error.

How can I copy both struct one inside of the other and still have access to the nested one?

  • 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-26T17:20:17+00:00Added an answer on May 26, 2026 at 5:20 pm

    Standard “deep copying” into shared memory is not useful because the pointers, even if they point into the shared memory segment, are local to your process’s virtual address space and won’t be the same when another process maps the shared memory. Instead of pointers, you need to store offsets from the beginning of the shared memory segment. size_t would be an appropriate type.

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

Sidebar

Related Questions

I have these two structures... typedef struct{ MY_SECOND_STRUCT s1; }MY_FIRST_STRUCT; typedef struct{ int s1;
Suppose I have the following two data structures: std::vector<int> all_items; std::set<int> bad_items; The all_items
Assume that we have two C# structures: [Serializable, StructLayout(LayoutKind.Sequential, Pack = 1)] public struct
I have two identical (but differently named) C structures: typedef struct { double x;
Say I have a database called Poll and have these two table structures. poll
I have some HTML that I need to toggle between two structures - one
In my code base I find that two modules have structures with the same
I have two database tables with the following structure: actions: action_id int(11) primary key
I have two structure in c struct data{ char *name; }; struct lst{ struct
I have two sources: an xml-file containing definitions of several hundred data structures, basically

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.