using output of function

Dear all

I have one question about functions . My program has 2 function+main function .
for example :

first function is
1
2
3
4
int combine(){
.....
return **A
} 


A is one dynamic int 2D array that is output of this function

second function is
1
2
3
4
5
6
7
bool ifConflict(int i , int j){

int **B ;

?

}


now my problem is here . I want to store A inside B (result of first function come to second function) . I write **B=combine() ; but it did not answer !!!!

would you please answer my question ?

Regards


Firstly, avoid 2d arrays. They're messy.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
int** combine(){//the type of your array is int**, so return an int**
   int ** A = (int**)calloc(4, sizeof(int*));
   for(int i = 0; i < 4; i++) A[i] = (int*)calloc(10, sizeof(int));
   return A;//A is the array. **A is only the first element of it
}

bool ifConflict(...){
   int **B = combine();
   //or
   int** C;
   C = combine();

   //don't forget to free the allocated memory.
}
Topic archived. No new replies allowed.