# 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.

## 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 on other sites
Arrggh, noob mistake!

Thanks heaps

1. 1
2. 2
Rutin
19
3. 3
4. 4
khawk
14
5. 5
A4L
13

• 13
• 26
• 10
• 11
• 44
• ### Forum Statistics

• Total Topics
633743
• Total Posts
3013643
×