We help IT Professionals succeed at work.

We've partnered with Certified Experts, Carl Webster and Richard Faulkner, to bring you two Citrix podcasts. Learn about 2020 trends and get answers to your biggest Citrix questions!Listen Now

x

# function prototype

on
Medium Priority
296 Views
..

int funcZ( int array[][], int k, int b,int  c )

{
... .. .. ..
Funcb(array[x][], k, b);
Funcb(array[][x], k, c);
...

}

int Funcb(int arr[], int k, int d )
{
....
}

b is binary search, but according to my code, array[][]'s first []'s search then other []'s search.. so of course it can not be compiled, how to correct it..
Comment
Watch Question

## View Solutions Only

Commented:
hi

what you want to do simply can not be done
for c, an [] specification means a contiguoes memory that holds x items of the same data type
when you specify [][x], the space you are refering to is not contiguoes, and the compiler can not treat it as a reguler [] type,

what you can do is create a [] from the data and then pass it to the function, for exapmle :
Funcb(array[x][], k, b);

int temp[];
int i;

for (i=0; i<array_size; ++i) {
temp[i] = array[i][x];
}

Funcb(temp, k, c);

momi

Not the solution you were looking for? Getting a personalized solution is easy.

Commented:
Do you want to do something with 2D array rows and columns? In this case try the following function:

int Funcb(int* arr,     /* pointer to first array member/*
int step,               /* distance between members/*
int size,               /* number of elements to handle*/
int k, int d )         /* your existing parameters - I don't know what they are */
{
int i;

for ( i = 0; i < size; i++ )
{
// work with *arr
// move to next element: increment arr to step
}
}

For example, you have 10*10 array. To handle array row, call Funcb with step = 1. To handle array column, call Funcb with step = 10.

Commented:
Correction:
To handle array column, call Funcb with step = 9.
##### Thanks for using Experts Exchange.

• View three pieces of content (articles, solutions, posts, and videos)
• Ask the experts questions (counted toward content limit)
• Customize your dashboard and profile