how do you copy one array to another?
that code doesn't work, does it?Code:array1 = array2;
how do you copy one array to another?
that code doesn't work, does it?Code:array1 = array2;
No. If you know the size of the array:Code:#define ARRAY_SIZE 3 int array1[ARRAY_SIZE] = {}; int array2[ARRAY_SIZE] = {1,3,4}; for (int i = 0; i < ARRAY_SIZE; i++) { array1[i] = array2[i]; }
memcpy? There are a few more, but they all pretty much do what's been shown above.
Quzah.
Hope is the first step on the road to disappointment.
Code:struct S { char arr[3]; }; int main( int argc, char *argv[] ) { struct S s1 = { {'1','2','3'} }; struct S s2 = { {'4','5','6'} }; s1 = s2; return 0; }