This is the program I'm working on. The task is to multiply 2 matrices. The number of columns in Matrix A are the same as the number of rows in Matrix B. I give the user the option to insert what the two matrices contain . this my code:
#include <stdio.h>
void multiplyMat(int n,int p,int c,int m,int d,int q,int k,int **multiply, 
int **first,int **second);
int main()
{
  int m, n, p, q, c, d, k;
  int first[10][10], second[10][10], multiply[10][10];
  printf("Enter number of rows and columns of first matrix\n");
  scanf("%d%d", &m, &n);
  printf("Enter elements of first matrix\n");
  for (c = 0; c < m; c++)
    for (d = 0; d < n; d++)
      scanf("%d", &first[c][d]);
  printf("Enter number of rows and columns of second matrix\n");
  scanf("%d%d", &p, &q);
  printf("Enter elements of second matrix\n");
  for (c = 0; c < p; c++)
     for (d = 0; d < q; d++)
        scanf("%d", &second[c][d]);
multiplyMat(n,p,c,m,d,q,k,multiply,first,second);
printf("Product of the matrices:\n");
for (c = 0; c < m; c++) {
  for (d = 0; d < q; d++)
    printf("%d\t", multiply[c][d]);
printf("\n");
}
return 0;
}
void multiplyMat(int n,int p,int c,int m,int d,int q,int k,int **multiply, 
int **first,int **second){
    int sum=0;
    if (n == p){
        for (c = 0; c < m; c++) {
           for (d = 0; d < q; d++) {
                for (k = 0; k < p; k++) {
                    sum = sum + first[c][k]*second[k][d];
                }
            multiply[c][d] = sum;
            sum = 0;
            }
        }
    }
    else
        printf("The matrices can't be multiplied with each other.\n");
}
I get the "segmentation fault". it happend when the code get in "sum = sum + first[c][k]*second[k][d]" what i do that cause it? maybe its happend because i use wrong defnion of pointers.
 
    