Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

function prototype

Posted on 2006-10-28
3
Medium Priority
?
262 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 37

Assisted Solution

by:momi_sabag
momi_sabag earned 1000 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 1000 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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Have you thought about creating an iPhone application (app), but didn't even know where to get started? Here's how: ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ Important pre-programming comments: I’ve never tri…
Summary: This tutorial covers some basics of pointer, pointer arithmetic and function pointer. What is a pointer: A pointer is a variable which holds an address. This address might be address of another variable/address of devices/address of fu…
The goal of this video is to provide viewers with basic examples to understand and use structures in the C programming language.
The goal of this video is to provide viewers with basic examples to understand opening and writing to files in the C programming language.

688 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