Array Comparison in C

Solved
Hello,
I would like to know if there is a command in C that allows you to compare two arrays and determine all the elements that these two arrays have in common.
Thank you.

15 answers

  1. Moderator
    If it's a character array, you can use strcmp (<string.h>). Otherwise

    int cmp_tab(int *tab1,int *tab2,int size){ // or whatever you want instead of "int" for(i=0;i<size;i++) { if (tab1[i]!=tab2[i]) return 0; } return 1; }


    or something like that...

    Note that if you can use C++, you can directly use the vector class and the == operator...
    4