C++ memory problem when trying to change parameter of array's object but only in loop

Viewed 33

So the case is this, procedure throws an memory error, while the other does not despite being pretty close to each other. This works fine:

    void asdfe() // no memory issues
    {
        nodes[3].X = 1;
    }

while this throws an error (access violation error to be precise):

    void SetPos(double x, double y, double z) // memory issues
    {
        for (unsigned int i = 0; i != sizeof(nodes) - 1; i++)
        {
            nodes[i].X = x;
            nodes[i].Y = y;
            nodes[i].Z = z;
        }
    }

nodes is simply array of 3d vectors

0 Answers
Related