This program must have a function that can accept 2 arrays and return their product in a third array. All of the arrays must be 2d, and a separate function must complete the multiplication of the elements memberwise. When I run this in visual studio I get the error:
Unhandled exception at 0x003f15ec in program4.exe: 0xC0000005:
Access violation reading location 0x00000000.
This could be due to my lack of knowledge about C++, but I think I may have made a syntax mistake or something. Here is the program:
#include<iostream>
using namespace std;
void ProductArrays(int[3][4], int[3][4], int** array3[3][4]);
void main()
{
int array1[3][4] = { {1,3,5,7}, {9,11,13,15}, {17,19,21,23} };
int array2[3][4] = { {2,4,6,8}, {10,12,14,16}, {18,20,22,24} };
int** array3[3][4] = {0,0,0,0,0,0,0,0,0,0,0,0};
ProductArrays(array1, array2, array3);
system("pause");
return;
}
void ProductArrays(int array1[3][4], int array2[3][4], int** array3[3][4])
{
int i,j;
for (i=0;i<3;i++)
{
for(j=0;j<4;j++)
{
**array3[i][j] = array1[i][j] * array2[i][j];
}
}
return;
}
void main()is non-standard. Useint main()and eitherreturn 0;or leave it out altogether. A good compiler should not acceptvoid main().