hey guys i got one more question :O

i have this code for a class function

void Platform::set_clips(SDL_Rect platClip[], int i)
{
	for( int j = 0; j < i; j++ )
	{
		platClip[j].x = 0;
		platClip[j].y = 0;
		platClip[j].w = random_number_w();
		platClip[j].h = 5;
	}
}

is this legal?! i mean in the parameters of the function i just put SDL_Rect platClip[] and when i actually call the function i will be putting SDL_Rect levelOnePlatform[50] will this work? it doesnt compile if i dont put the [] int the function definition parameter.

Thanks a bunch :D

If you're trying to pass the array to the function, you should just pass the name of the array "levelOnePlatform" as the first argument and 50, as the second argument which is its size.

>>will this work?

Just try it:

void foo(int bar[], int sz) {
  for(int i = 0; i < sz; ++i) 
    bar[i] = 42;
};

int main() {
  int b[50];
  foo(b,50);
  return 0;
};

and yes, it works.

thanks for the quick replies guys!

but i guess what chilton said worked and is much easier to follow :P

thanks though mike!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.