I am trying to now multiply matrices stored in 2d arrays. When the program runs i get segmentation fault, using DDD i found the point where it stops after 3 loops.
int i,j,k;
float** matrixc = new float*[rows];
if (matrixc != NULL)
{
for (int x = 0; x < rowsa; x++)
{
matrixc[x] = new float[columnsb];
}
}
for (i = 1; i <= rowsa; i++)
{
for (j = 1; j <= columnsb; j++)
{
float sum = 0;
for (k = 1; k <= rowsb; k++)
{
*/seg fault occurs here*/ sum = sum + matrixa[i][k] * matrixb[k][j];
}
matrixc[i][j] = sum;
cout << " " << sum[i][j];
}
cout << endl;
}
This is my code, there isnt anything wrong with it to my knowledge, and i cant determine why i get a seg fault