Pointers and Arrays of Structs
I understand this is a commonly asked question but i've still yet managed
to find a solution.
I have create an array of a struct path called location path
location[numLevels*levelSize];
I am also using a stack of paths called start.
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.
bool moveLocationStack(const vector <vector<path> > &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->type=spaceStation.at(y).at(x).type;
square->type=spaceStation.at(y).at(x).visit;
square->type=spaceStation.at(y).at(x).inPath;
square->type=spaceStation.at(y).at(x).level;
return 1;
}
return 0;
}
The pointer square should point to the next location of the array sent to
it by the function call I try to be
if(moveLocationStack(spaceStation,possibleX,possibleY,location[currentLocation])){
}
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.
Any way to explain this so I can understand the error?
No comments:
Post a Comment