• Advertisement

Archived

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

How to make an array of structs? c++

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

ok, so... HBITMAP myStruct[x][y]; //for bitmaps int myStruct[x][y]; //for numbers but how do i make an array of structures? thanks in advance

Share this post


Link to post
Share on other sites
Advertisement
struct _mystruct
{
int field1;
int field2;
} myStruct[x][y];

========
OR
========

typedef struct _mystruct
{
int field1;
int field2;
} MYSTRUCT;

MYSTRUCT myStruct[x][y];


You reference the fields like this:

myStruct[0][0].field1
myStruct[0][0].field2



[edited by - Dave Hunt on February 7, 2003 2:03:58 PM]

Share this post


Link to post
Share on other sites
You don''t need to typedef in C++.

struct MyStruct
{
int x, y;
};

MyStruct structArray[32];

Share this post


Link to post
Share on other sites
quote:
Original post by cgoat
You don''t need to typedef in C++.

struct MyStruct
{
int x, y;
};

MyStruct structArray[32];


True, but it doesn''t hurt.

Share this post


Link to post
Share on other sites
bingo cgoat, finally i understand what someone is saying lol, that is exactly what i wanted, and it seems to be working so far...
thanks

Share this post


Link to post
Share on other sites

  • Advertisement