Jump to content
  • Advertisement

Archived

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

when4

How to make an array of structs? c++

This topic is 5766 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
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
×

Important Information

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

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!