Q:

Returning malloc from a function in C

I have been trying to return a malloc from a function for three days now, however without joy. 
my code is as follows what i am trying to do is pass two one dimensional array and perform matrix calculation, then return the result in a two dimensional array.  the code is as follows:
int **func1(numrow, numcol, *temp, *word){

int  i, c, d;
int **pointer;

pointer = (int**)malloc( numrow * sizeof(int*);

        for(i=0; i<numrow; i++){
           pointer[i] = (int*)malloc( numcol * sizeof(int*) );    
        }

        for ( c = 0 ; c < numrow ; c++ )
            for ( d = 0 ; d < numcol ; d++ )
                    pointer[c][d] =( (temp[c] - word[r]) * (temp[c] - word[r])     );   

    return pointer;

}

int main(){

int **poi, r, c, numcol, numrow;
int templet[8] = {1, 1, 1, 1, 3, 4, 4, 4 };
int newWord[8] = {1, 1, 4, 4, 4, 5, 0, 0 };

printf("please enter the number of rows:\n");
scanf("%d%d",&numrow, &numcol);

    poi = func1(numrow, numcol, templet, newWord );

        for(r=0; r<numrow; r++)
            for(c=0; c< numrow; c++)

                printf("%d\n",*(*(poi + r) + c));

return 0;
}

A:

First change your function declarator to  
int **func1(int numrow, int numcol, int *temp, int *word)

then replace r by d in  
pointer[c][d] =( (temp[c] - word[r]) * (temp[c] - word[r]));   

and finally  
printf("%d\n",*(*(poi + r) + c));

to
printf("%d\n",poi[r][c]);    

Corrected code:  
int **func1(int numrow, int numcol, int *temp, int *word) {

int  i, c, d;
int **pointer;

pointer = malloc(numrow * sizeof(int*));

    for (i = 0; i < numrow; i++){
       pointer[i] = malloc(numcol * sizeof(int));
    }

    for ( c = 0 ; c < numrow ; c++ )
        for ( d = 0 ; d < numcol ; d++ )
                pointer[c][d] =( (temp[c] - word[d]) * (temp[c] - word[d]));

    return pointer;
}

int main(void){
    int **poi, r, c, numcol, numrow;
    int templet[8] = {1, 1, 1, 1, 3, 4, 4, 4 };
    int newWord[8] = {1, 1, 4, 4, 4, 5, 0, 0 };

    printf("please enter the number of rows and columns:\n");
    scanf("%d%d", &numrow, &numcol);
    poi = func1(numrow, numcol, templet, newWord);
    for (r = 0; r < numrow; r++)
        for(c = 0; c  numrow; c++)
            printf("%d\n",poi[r][c]);
        return 0;
}  

Possible suggestions:  

Learn to indent code properly. 
Debug your code many times as possible before asking here.  
Turn on your compiler warnings (like -Werror, -pedantic etc).