Skip to main content
added 151 characters in body
Source Link
user3014282
  • 211
  • 2
  • 12

How to copy row of 2d array to 1d array?

I was sure before I done it by assign like that:

  int x,y;
  scanf("%d%d", &x,&y);   
  int one[x];
  int two[y][x]; 
  one=two[0];

But now it gives me error :

incompatible types in assignment

EDIT:

Ok, my bad. I forgot that I can't copy arrays in such way, but I can pass single row of 2d array to function as an argument. Solved.

How to copy row of 2d array to 1d array?

I was sure before I done it by assign like that:

  int x,y;
  scanf("%d%d", &x,&y);   
  int one[x];
  int two[y][x]; 
  one=two[0];

But now it gives me error :

incompatible types in assignment

How to copy row of 2d array to 1d array?

I was sure before I done it by assign like that:

  int x,y;
  scanf("%d%d", &x,&y);   
  int one[x];
  int two[y][x]; 
  one=two[0];

But now it gives me error :

incompatible types in assignment

EDIT:

Ok, my bad. I forgot that I can't copy arrays in such way, but I can pass single row of 2d array to function as an argument. Solved.

Source Link
user3014282
  • 211
  • 2
  • 12

Copying row of 2d array to 1d array

How to copy row of 2d array to 1d array?

I was sure before I done it by assign like that:

  int x,y;
  scanf("%d%d", &x,&y);   
  int one[x];
  int two[y][x]; 
  one=two[0];

But now it gives me error :

incompatible types in assignment