When passing a multidimensional array to a function, the function must know the size of all dimensions of the array, except for the outermost dimension. Otherwise, if these sizes are unknown, then the compiler will not know how to calculate the memory address of the array elements.
For example, if you index into the array arr by using the expression arr[3][5] inside the body of the function thisFunc, then, in order to retrieve the corresponding value from the array, the compiler doesn't need to know the size of the outer array, but it needs to know the size of the inner array. If it for example knows that the size of the innermost array is 8, then it will know that you want to access the 30th element of the array (3*8+5==29, which corresponds to index 29 in 0-based indexing and index 30 in 1-based indexing).
In this case, you seem to want the size of the inner arrays to be 2, so you should change the line
void thisFunc(int arr){
to:
void thisFunc(int arr[][2]){
Another issue is that the line
int arr[2] = {bob, jim};
will not work, for two reasons:
The type of the array should be int arr[2][2] instead of int arr[2] if you want it to contain two sub-arrays of two elements each.
You cannot copy an array like that. However, you can copy an array using the function memcpy.
Here is an example of copying an array using memcpy:
int bob[2] = {12, 13};
int jim[2] = {20, 50};
int arr[2][2];
memcpy( arr[0], bob, sizeof arr[0] );
memcpy( arr[1], jim, sizeof arr[1] );
You can also initialize the array content directly, for example like this:
int arr[2][2] = {
{ 12, 13 }, //bob
{ 20, 50 } //jim
};
That way, you won't need the additional arrays bob and jim and you also won't need to use memcpy.
The entire code would look like this, assuming that the inner array has a fixed size of 2 elements:
#include <stdio.h>
#include <string.h>
void thisFunc( int arr[][2] )
{
int firstValOfBob = arr[0][0];
int secondValOfBob = arr[0][1];
printf( "firstValOfBob: %d\n", firstValOfBob );
printf( "secondValOfBob: %d\n", secondValOfBob );
}
int main()
{
int arr[2][2] = {
{ 12, 13 }, //bob
{ 20, 50 } //jim
};
thisFunc(arr);
}
This program has the following output:
firstValOfBob: 12
secondValOfBob: 13