I am attempting to convert a 2D array to 1D. I\'m extremely new to C/C++ but I think it\'s very important to learn how to convert a 2D array to 1D. So here I am stumbling u
This code
int n=0,m=0; // 2D array nRow, nCol
int a[n][m];
is invalid. First of all the dimensions shall be constant expressions and there is no sense to set them to 0.
And the more simple way to do your task is to use pointer. For example
int *p = b;
for ( const auto &row : a )
{
for ( int x : row ) *p++ = x;
}