Archived

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

shalrath

Array woes!

Recommended Posts

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