Jump to content
  • Advertisement


This topic is now archived and is closed to further replies.


FOR loop acting strange

This topic is 5647 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

    CUSTOMVERTEX m_Vertices[40000];
	long vcount=0;
    for(int x=0;x<201;x++)
		for(int z=0;z<201;z++)
			m_Vertices[vcount].x     = x;
			m_Vertices[vcount].y     = Heightmap[x][z];
			m_Vertices[vcount].z     = z;
			m_Vertices[vcount].color = 0xffffffff;
			m_Vertices[vcount].tu    = 1;
			m_Vertices[vcount].tv    = 1;
When I try to run this code, I get an access error, so I run it in debug mode and check the value of vcount and its 1128726528 which seems to be impossible for two nested for loops that go up to 100 to reach. The max that vcount can reach should be 40,000 shouldn''t it? Anyways, why is this code giving me an access error. Specifically , it points to the line "m_Vertices[vcount].y = Heightmap[x][z]; but I''m kinda thinking the problem with vcount is causing it.. Thanks ----- GSACP: GameDev Society Against Crap Posting To join: Put these lines in your signature and don''t post crap!

Share this post

Link to post
Share on other sites
the loop doesn't go up to 201 though.. it only reaches 200 (hence the x<201)

EDIT: nevermind, that solves it! (and about another 100 c++ problems I've had in the past)
lol thanks

[edited by - Xtremehobo on July 3, 2003 1:33:04 PM]

Share this post

Link to post
Share on other sites

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!