C: create an array of array with memcpy -


i'm trying create , fill array of array. code i've written:

int b[4] = {100, 100, 200, 300}; int a[2][4];  int main(){     memcpy(a[0], b, sizeof(int));     printf("%i", a[0][2]); 

i shoulde 200, instead 0...how can solve it?

you're copying 1 int b. need copy of b a[0] this

int b[4] = {100, 100, 200, 300}; int a[2][4];  int main(){     memcpy(a[0], b, sizeof(b));     printf("%i", a[0][2]); } 

Comments

Popular posts from this blog

'hasOwnProperty' in javascript -

How to put a lock and transaction on table using spring 4 or above using jdbcTemplate and annotations like @Transactional? -

How to understand 2 main() functions after using uftrace to profile the C++ program? -