Archived

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

shalrath

Array woes!

Recommended Posts

shalrath    128
I wish to make a multi dimentional array for my current tile engine, I declare my structure for texture selection like this: struct tilemap_t { int texid; }; an then the array like this: tilemap_t tile[10][10]; However, Visual C++ reports the error !!! I have no idea, any thoughts?

Share this post


Link to post
Share on other sites
Dean Harding    546
There''s nothing wrong with what you''ve given, what is the exact error? And post a few lines around the code you''ve given. Often the error is not on the line that VC reports, but on a line above...


War Worlds - A 3D Real-Time Strategy game in development.

Share this post


Link to post
Share on other sites
BlueMonk    142
I think sometimes (depending on the compiler?), if you''re declaring a variable of a struct type you have to use:

struct tilemap_t tile[10][10];

instead of:

tilemap_t tile[10][10];

"All you need to do to learn circular logic is learn circular logic"

Share this post


Link to post
Share on other sites
xstreme2000    152
I think BlueMonk has the answer. What you could do is make it into a type:

typedef struct {
int texid;
} tilemap_t;

then carry on as before

tilemap_t tile[10][10];

Hope that useful

Share this post


Link to post
Share on other sites
Sandman    2210
C++ implicitly typedefs classes and structures. This would only cause a problem if the compiler is using C rules (which it does only if you use files with the .c extension instead of .cpp)

Share this post


Link to post
Share on other sites