Comparing Arrays

I need to know how to compare the elements in two arrays. Like a one-to-one comparison, both of the arrays don't need to be 100% equal

Like for 2485 and 3495, [1] and [3] match
1
2
3
4
5
6
7
8
9
10
int arr1[3] = {1,2,3};
int arr2[5] = {5,3,4,2,1};

for(int i = 0; i < 3; i++)
{
    for(int j = 0; j < 5; j++)
    {
        if(arr1[i] == arr2[j]) // this will compare every number in the first array with every number in the second one
    }
}


Keep in mind my if statement checks if they're equal. I don't know what you want to compare.
Last edited on
Topic archived. No new replies allowed.