Yahoo Answers is shutting down on May 4th, 2021 (Eastern Time) and beginning April 20th, 2021 (Eastern Time) the Yahoo Answers website will be in read-only mode. There will be no changes to other Yahoo properties or services, or your Yahoo account. You can find more information about the Yahoo Answers shutdown and how to download your data on this help page.

Variable Size Multi Dimensional Array Casting?

Hi all.

This is my first post so before I start begging for help let me first say that I am very grateful to the people who contribute and created this site. It has been invaluable to me for quick and easy reference. So thank you, hugely.

Now to my "problem". I am working with a game engine library, and for the most part everything is great. I just have a small issue that I would ideally like to fix. The library does many things, one of which is supply Game Map data.

int s_x, int s_y;

char* mapData=(char*)MapData(s_x,s_y);

s_x and s_y are output vars which receive the dimensions of the 2D map (W x H), each map element is comprised of 8 bytes, s_x of these form 1 row and s_y rows form the entire data block.

At the moment I can access byte (n) of the element at a particular row (y) and column (x) like this:

mapData[ (s_x*y*8) + (x*8) + n ]

What would be very useful to me is if I could access an element like this:

mapData[y][x][n]

So far I have not been able to find any information on casting the pointer to a multidimsional array type. I can do it if the map size is always the same using a typedef but I cannot work out or find out how to cast to variable sizes or if it's even possible.

Many thanks for any help.

Alain.

1 Answer

Relevance
  • Anonymous
    10 years ago
    Favorite Answer

    Sorry, I don't know the answer to your question, but I think you'd have a much better response if you took it to StackOverflow.net. That seems to be the best place to ask for coding help, and it should also have more experienced programmers. Good luck!

Still have questions? Get your answers by asking now.