I have the following code of declarations:
struct coord {
int x;
int y;
}
void rotateFig(struct coord[10][10]);
I need to implement rotateFig.
I tried to start with following:
void rotateFig(struct coord[10][10] c)
{
//code
}
I can`t compile it – probaly the way I transfer c in the function definition is incorrect .How should I transfer c using given signature.
Thank you
struct coordis a type andcis a variable of typestruct coordwhich can hold10 X 10struct coordelements.So it should be as follows
One thing to note when working with multi-dimension array in
Cis that it cannot be return back from a function. For details, read this. So its not advised to use the above format asCby default passes arguments by value and not by address.So as @Mr.TAMER mentioned in his answer, you should use the following
OTOH, you can use the following rotate code for your reference! It rotates a 2d array to 90 degrees!
Hope this helps!