Solved

function prototype

Posted on 2006-10-28
3
252 Views
Last Modified: 2010-04-15
..

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..
0
Comment
Question by:thefirstfbli
  • 2
3 Comments
 
LVL 37

Assisted Solution

by:momi_sabag
momi_sabag earned 250 total points
ID: 17826311
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
0
 
LVL 48

Accepted Solution

by:
AlexFM earned 250 total points
ID: 17826482
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.
0
 
LVL 48

Expert Comment

by:AlexFM
ID: 17828233
Correction:
To handle array column, call Funcb with step = 9.
0

Featured Post

ScreenConnect 6.0 Free Trial

Explore all the enhancements in one game-changing release, ScreenConnect 6.0, based on partner feedback. New features include a redesigned UI, app configurations and chat acknowledgement to improve customer engagement!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

An Outlet in Cocoa is a persistent reference to a GUI control; it connects a property (a variable) to a control.  For example, it is common to create an Outlet for the text field GUI control and change the text that appears in this field via that Ou…
Windows programmers of the C/C++ variety, how many of you realise that since Window 9x Microsoft has been lying to you about what constitutes Unicode (http://en.wikipedia.org/wiki/Unicode)? They will have you believe that Unicode requires you to use…
The goal of this video is to provide viewers with basic examples to understand recursion in the C programming language.
The goal of this video is to provide viewers with basic examples to understand opening and reading files in the C programming language.

776 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question