<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic In C, going to create a new long nested structures in Developers Questions</title>
    <link>https://community.esri.com/t5/developers-questions/in-c-going-to-create-a-new-long-nested-structures/m-p/1252861#M6484</link>
    <description>&lt;P&gt;What is the best/cleanest approach to start (in a local function) a lengthy chain of &lt;A href="https://www.scaler.com/topics/c/nested-structure-in-c/" target="_self"&gt;nested&lt;/A&gt; structures where each structure just holds pointers to other structures, as seen below:&lt;/P&gt;&lt;LI-CODE lang="c"&gt;typedef struct A{
struct B{
    struct C *c /* OPTIONAL */;
    struct D *d /* OPTIONAL */;
    struct E *e /* OPTIONAL */;
    struct F *f /* OPTIONAL */;
} *b;
struct G{
    struct F *f /* OPTIONAL */;
    struct D *d /* OPTIONAL */;
    struct H *h /* OPTIONAL */;
    struct F *f /* OPTIONAL */;
} *g;
    } a;&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Each of the references to the nested structures link to structures that contain pointers to other nested structures (I know, it's weird!)&lt;/P&gt;&lt;P&gt;I believe I need to define a tmp pointer for each struct member and allocate memory for it, as well as a tmp struct variable and point the former to the latter:&lt;/P&gt;&lt;LI-CODE lang="c"&gt;B *b_ptr = CALLOC(1,sizeof(b_ptr));
B b_tmp;
b_ptr = &amp;amp;b_tmp;
b_tmp.itsMember1 = CALLOC(1,sizeof(itsMember1));
TypeOfItsMember1 itsMember1_tmp;
..
..&lt;/LI-CODE&gt;&lt;P&gt;This will necessitate a plethora of local variables and excruciatingly repetitious code. Is there a better method to thoroughly initialise the parent struct?&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 30 Jan 2023 14:32:33 GMT</pubDate>
    <dc:creator>hectorsalamanca</dc:creator>
    <dc:date>2023-01-30T14:32:33Z</dc:date>
    <item>
      <title>In C, going to create a new long nested structures</title>
      <link>https://community.esri.com/t5/developers-questions/in-c-going-to-create-a-new-long-nested-structures/m-p/1252861#M6484</link>
      <description>&lt;P&gt;What is the best/cleanest approach to start (in a local function) a lengthy chain of &lt;A href="https://www.scaler.com/topics/c/nested-structure-in-c/" target="_self"&gt;nested&lt;/A&gt; structures where each structure just holds pointers to other structures, as seen below:&lt;/P&gt;&lt;LI-CODE lang="c"&gt;typedef struct A{
struct B{
    struct C *c /* OPTIONAL */;
    struct D *d /* OPTIONAL */;
    struct E *e /* OPTIONAL */;
    struct F *f /* OPTIONAL */;
} *b;
struct G{
    struct F *f /* OPTIONAL */;
    struct D *d /* OPTIONAL */;
    struct H *h /* OPTIONAL */;
    struct F *f /* OPTIONAL */;
} *g;
    } a;&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Each of the references to the nested structures link to structures that contain pointers to other nested structures (I know, it's weird!)&lt;/P&gt;&lt;P&gt;I believe I need to define a tmp pointer for each struct member and allocate memory for it, as well as a tmp struct variable and point the former to the latter:&lt;/P&gt;&lt;LI-CODE lang="c"&gt;B *b_ptr = CALLOC(1,sizeof(b_ptr));
B b_tmp;
b_ptr = &amp;amp;b_tmp;
b_tmp.itsMember1 = CALLOC(1,sizeof(itsMember1));
TypeOfItsMember1 itsMember1_tmp;
..
..&lt;/LI-CODE&gt;&lt;P&gt;This will necessitate a plethora of local variables and excruciatingly repetitious code. Is there a better method to thoroughly initialise the parent struct?&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 30 Jan 2023 14:32:33 GMT</pubDate>
      <guid>https://community.esri.com/t5/developers-questions/in-c-going-to-create-a-new-long-nested-structures/m-p/1252861#M6484</guid>
      <dc:creator>hectorsalamanca</dc:creator>
      <dc:date>2023-01-30T14:32:33Z</dc:date>
    </item>
  </channel>
</rss>

