How to make an array of structs? c++

Started by
3 comments, last by when4 21 years, 2 months ago
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
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]
You don''t need to typedef in C++.

struct MyStruct
{
int x, y;
};

MyStruct structArray[32];
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.
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

This topic is closed to new replies.

Advertisement