Trouble with array with function

Hi, I am having trouble to the following problem. Can someone please explain it to me? Thanks for advance


Write a function called dropDimension that copies the entries from a 2-dimensional array row by row as the entries of a 1-dimensional array. Assume that the 1-dimensional array has more than enough capacity
for these entries. (The function should use capacities of the 2-dimensional array but not the 1-dimensional array as
input parameters.)

For example, a program that uses the function follows.

1
2
3
4
5
6
7
8
9
  int main() {
      int x[100];
      int y[2][3] = {{3,1,4}, {1,5,9}};
      int yrows = 2, ycols = 3;
      dropDimension(y, yrows, ycols, x);
      for (int i = 0; i <= 5; i++) cout << x[i];  // 314159 is printed
      cout << endl;
      return 0;
      }
Topic archived. No new replies allowed.