Note that there are some explanatory texts on larger screens.

plurals
  1. POUnhandled exception when pushing_back an item to a vector contained in a vector
    primarykey
    data
    text
    <p>I am finding some difficulties when I try to iterate with a vector that contains another vector inside. I have a header file which defines a structure like this: typedef struct Set{ char varname[32]; void * value; } Set;</p> <pre><code>typedef struct Setup { float instant; std::vector&lt;Set *&gt; SetVar; } Setup; std::vector&lt;Setup *&gt; TestCase; </code></pre> <p>In the cpp, I have a function that simply reads an xml file and parses the readen value to the TestCase vector, like this:</p> <pre><code>while(SetupHandle.ToElement()){ Setup * newSetup = (Setup *)malloc(sizeof(Setup)); str = SetupHandle.ToElement()-&gt;Attribute("instant"); newSetup-&gt;instant = atof(str); TiXmlHandle SetHandle = SetupHandle.FirstChild("Set"); i=0; while(SetHandle.ToElement()){ Set * newSet = (Set *)malloc(sizeof(Set)); str = SetHandle.ToElement()-&gt;Attribute("Variable"); strcpy(newSet-&gt;varname, str); const char * newstr = SetHandle.ToElement()-&gt;Attribute("Value"); newSet-&gt;value = (void *) newstr; newSetup-&gt;SetVar.push_back(newSet); i++; SetHandle = SetupHandle.Child("Set", i); } TestCase.push_back(newSetup); index++; SetupHandle = TC_top.Child("Setup", index); } </code></pre> <p>The library compiles, but when when I use it, the program crashes in the line that says "newSetup->SetVar.push_back(newSet);". It throws an unhandled exception saying: "Unhandled exception at 0x0430d7ba (tcmodule_psttm_isorc2014_d.pyd) in ISORC2014_CaseStudy_d.exe: 0xC0000005: Access violation reading location 0xcdcdcdc1."</p> <p>Does somebody know what am I doing wrong?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload