Sign in to follow this  

Data structure and array problem

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

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