PlayArea* playarea[10][20];
CrystalApp::CrystalApp()
: ...
{
ZeroMemory(object, sizeof(object) );
ZeroMemory(object1, sizeof(object1) );
ZeroMemory(crystal_a, sizeof(crystal_a) );
ZeroMemory(crystal_b, sizeof(crystal_b) );
for( int j=0; j<10; j++)
{
ZeroMemory(playarea[j], sizeof(playarea[j]) );
}
}
zeromemory
i have a problem understanding this portion of the code:
this constructor is trying to initialize the array of pointers.
the 1st 4 zeromemory codes are for 1D array of pointers.
what i dun understand is the playarea portion which is
2D. Am i initializing it correctly?
anyone who can clarify my doubts will be most appreciated.
Just do another sizeof based ZeroMemory. It''s a contiguous array, so it''s safe.
No like this:
ZeroMemory(playarea, sizeof(playarea[0])*10);
But the code you wrote in your original post should also be fine. What is it you don''t understand about it?
ZeroMemory(playarea, sizeof(playarea[0])*10);
But the code you wrote in your original post should also be fine. What is it you don''t understand about it?
Jacob Marner, M.Sc.Console Programmer, Deadline Games
Edwinnie and felonius, you both posted the same thing . Yes, Edwinnie, that''s what I meant. If you''re being confused by the pointer part of that 2D array, remember that''s the ''last'' part ''interpreted''. I.E. it''s an 10 by 20 array of pointers to PlayAreas. So, on 32bit platforms, sizeof(playarea) is 800; and sizeof(playarea[0]) is 80, which we multiply by 10 to get 800.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement