I'm writing a code that is suppose to display the sum of two arrays added together into one array. Also The results are suppose to be displayed using subscripts and pointers. I have the subscript part down, but on the pointer part I am getting an error that says: C2440: '=' : cannot convert from 'int[4][5]' to 'int*'. Why can it not convert the array and how would I go about fixing this? The error is being shown in line 12.
#include <iostream>
#include <ctime>
using namespace std;
int main()
{
srand((unsigned)time(0));
const int numRows=4, numCols=5;
int A[numRows][numCols]={0}, B[numRows][numCols]={0};
int C[numRows][numCols];
int *ArrayPointer;
This will work for the initial assignment. Multi-Dimensional arrays are more complex. You can't assign the name of the MD array to a pointer as you can with a 1D array. To be honest I'm not really sure I understand that and since I rarely use MD arrays I have never thought much about it. You should search around for more threads and articles. This issue has been discussed numerous times. ArrayPointer = &C[0][0];