Jump to content
  • Advertisement
Sign in to follow this  

Data structure and array problem

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

Hi Guys,

I am having a bit of a problem with an array of data structures.

The custom data structure is;

struct Float6
	float x0;
	float y0;
	float x1;
	float y1;
	float x2;
	float y2;
I am initialising the structure like this;

Float6 collisionMap[] =
	(0.0f, -7.72136f, 0.0f, 0.0f, 56.0f, -7.72136f),
	(0.0f, 0.0f, 0.151287f, 0.049888f, 56.0f, -7.72136f)
When I read the first line back it keeps returning -7.72136

This is how I am reading back;

		std::string szBuffer = "";
		std::stringstream ss;
		ss << collisionMap[0].x0;
		szBuffer += "[0].x0 = ";
		szBuffer += ss.str();

		ss << collisionMap[0].y0;
		szBuffer += "   [0].y0 = ";
		szBuffer += ss.str();

		ss << collisionMap[0].x1;
		szBuffer += "   [0].x1 = ";
		szBuffer += ss.str();

		ss << collisionMap[0].y1;
		szBuffer += "   [0].y1 = ";
		szBuffer += ss.str();

		ss << collisionMap[0].x2;
		szBuffer += "   [0].x2 = ";
		szBuffer += ss.str();

		ss << collisionMap[0].y2;
		szBuffer += "   [0].y2 = ";
		szBuffer += ss.str();

		MessageBox(0, szBuffer.c_str(), "Data", 0);

Any assistance as to why I am getting the same value (-7.72136) in every position would be greatly appreciated.

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • 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!