Advertisement

Array woes!

Started by June 28, 2001 06:42 AM
5 comments, last by shalrath 23 years, 7 months ago
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?
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.
Advertisement
Whats the error message?
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"
"All you need to do to learn circular logic is learn circular logic"
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
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)
Advertisement
Try declaring you struct as "const" in the Structure definition.

"There is humor in everything depending on which prespective you look from."
"There is humor in everything depending on which prespective you look from."

This topic is closed to new replies.

Advertisement