Original Post
hey everyone- I know this may sound very, very noobish, but how do you use an array as a parameter in a function? (an integer array) like int draw_map(int map[WHAT_DO_I_PUT_HERE][AND_HERE])
int foo[32][64];int foo[32][64];void init_first_10( int * ptr, int stride ) { for( int ix = 0; ix < 10; ++ix ) { int * tmp = &ptr[stride*ix]; for( int iy = 0; iy < stride; ++iy ) { tmp[iy] = 0; } }}int main() { init_first_10( foo, 64 ); return 0;}int foo[32][64];void init_first_10( int ptr[][64] ) { for( int ix = 0; ix < 10; ++ix ) { for( int iy = 0; iy < 64; ++iy ) { ptr[ix][iy] = 0; } }}int main() { init_first_10( foo ); return 0;}This topic has been locked by a moderator. New replies are not allowed.
With your permission, GameDev.net uses analytics cookies to understand how people use the platform. You can accept analytics or continue with necessary cookies only. Learn more