Global Variables Erasing

I've got to use three global variables:

int maxX = 0;
int maxY = 0;
vector<vector<char>> mapVector(25, vector<char>(37));

I'm initializing maxX and maxY in one fucntion

...
maxY = newString.size();
maxX = linesCount;
...

and the last one in another:

for (size_t i = 0; i < maxX; i++)
{
for (size_t j = 0; j < maxY; j++)
{
if (mapBuffer[y] != '\n')
{
mapVector[i][j] = mapBuffer[y];
y++;
}
if ((mapBuffer[y] == '\n') || (mapBuffer[y] == '\0'))
{
for (size_t x = j + 1; x < maxY; x++)
{
mapVector[i][x] = ' ';
}
y++;
break;
}
}
}


So, the thing is, when I try to access the "vector<vector<char>> mapVector(25, vector<char>(37));" from some other fucntion, the variable appears to be empty, but the maxX and maxY are not. That's weird. Why do you think that happens?
Last edited on
You have to show your exact declaration and implementation. There are many ways to code what you've described that do not work, it'll save everyone a lot of time if you post your actual code.
Topic archived. No new replies allowed.