Note that there are some explanatory texts on larger screens.

plurals
  1. POPointers and Arrays of Structs
    text
    copied!<p>I understand this is a commonly asked question, but i've still yet managed to find a solution.</p> <p>I have create an array of a struct path called location path <code>location[numLevels*levelSize];</code></p> <p>I am also using a stack of paths called start.</p> <p>The problem is transferring the proper location in the array to a function, having it create a new path to put in the array, than send it back.</p> <pre><code>bool moveLocationStack(const vector &lt;vector&lt;path&gt; &gt; &amp;spaceStation,const int x,const int y,path *square){ char c=spaceStation.at(y).at(x).type; if(c!='#'){ if(!spaceStation.at(y).at(x).visit and !spaceStation.at(y).at(x).inPath) square-&gt;type=spaceStation.at(y).at(x).type; square-&gt;type=spaceStation.at(y).at(x).visit; square-&gt;type=spaceStation.at(y).at(x).inPath; square-&gt;type=spaceStation.at(y).at(x).level; return 1; } return 0; } </code></pre> <p>The pointer square should point to the next location of the array sent to it by the function call I try to be:</p> <pre><code> if(moveLocationStack(spaceStation,possibleX,possibleY,location[currentLocation])){ } </code></pre> <p>It has an issue with sending the specific array section i want pointed to indexed by a variable elsewhere in the code currentLocation. If I just write location it works but I'm pretty sure it won't point to the next available space in the array everytime its called even if i increment currentLocations.</p> <p>Any way to explain this so I can understand the error?</p>
 

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