Sign in to follow this  

How is an INT an invalid array subscript?

This topic is 4589 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

80 C:\Documents and Settings\Jimmy\Desktop\Jim'sFortress\OpenGL\Jim'sPrograms\gravity.cpp invalid types `GLfloat[int]' for array subscript This is the line it will highlight: xPull[index] = acc * cos(xyAngle); This is how it was declared: GLfloat xPull[MAX_PLANETS]; (MaxPlanets was defined with #define)

Share this post


Link to post
Share on other sites
index was a parameter in the function

function was created as:
void updatePull(GLfloat massPull,GLfloat xPull,GLfloat yPull,GLfloat zPull,GLfloat radiusPull,int index){...}

and called as:
for(int i = 0; i < MAX_PLANETS; i++)
tester.updatePull(planets[i].mass,planets[i].x,planets[i].y,planets[i].z,planets[i].radius,i);

Share this post


Link to post
Share on other sites
Quote:
Original post by SirOnion
index was a parameter in the function

function was created as:
void updatePull(GLfloat massPull,GLfloat xPull,GLfloat yPull,GLfloat zPull,GLfloat radiusPull,int index){...}

and called as:
for(int i = 0; i < MAX_PLANETS; i++)
tester.updatePull(planets[i].mass,planets[i].x,planets[i].y,planets[i].z,planets[i].radius,i);


Your paramter GLfloat xPull is wrong. It should be GLfFloat *xPull.
A to why I leave that as a exercise to a reader.

Share this post


Link to post
Share on other sites

This topic is 4589 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this