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

javascript - Confirm a form & display message if form is valid with JQuery -

Retrieving ETA (estimated time of arrival) with Google Distance Matrix API and public transit as transport mode -

ionic framework - Meteor - Error: Failed to execute 'insertBefore' on 'Node' -