Solved

function prototype

Posted on 2006-10-28
3
248 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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
In desperate need of help 8 129
Goodbye, so long 10 91
Test against App 49 129
Why adding test code changes the build ? 11 124
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…
Video by: Grant
The goal of this video is to provide viewers with basic examples to understand and use for-loops 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.

706 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now