# Thread: question relating to arrays

1. ## question relating to arrays

Hey guys, i've had sooo much trouble with just something that is probably really simple, would appreciate the answer please I'm trying to make one array equal to another array, to make it worse i'm trying to make an array of a struct equeal to another one of the same type but I dont think that is the issue I think its just getting one array to equal another, below is sort of a list i made of things ive tried that have not worked Code:
```int arrayOne = {6, 5, 7, 3, 2, 5, 6, 5, 4, 5};
int arrayTwo;

arrayTwo = arrayOne;
arrayTwo = arrayOne;   //I'm guessing this will just make the 10th element equal to //arrayOne's 10th element, which is probably stupid since its the null terminator???```
should I just make a for loop to do it or is there an easier way????

Thanks for the help. 2. I'm not sure if I get what you are saying correctly but you should use '==' for comparison, and '=' for assignment. You could use a loop to iterate through the array and determine if they are equal or you could use memcmp, like this.

Code:
```#include <stdio.h>
#include <string.h>

int main()
{
int array1 = {1,2,3};
int array2 = {1,2,3};

if(memcmp(array1, array2, sizeof(array1)) == 0)
puts("equal");
else
puts("unequal");

return 0;
}``` 3. As far as I know, you're going to need to loop through the arrays and set each element of arrayTwo to its corresponding element in arrayOne. A for loop would do best, I think. 4. Are you trying to copy one array to the other? If so you could use memcpy, assuming the arrays are of the same type and size of course. Popular pages Recent additions 