Best way to compare two int arrays of the same length?

前端 未结 4 923
日久生厌
日久生厌 2020-12-09 19:45

what is the best way to compare int arrays b and c with a:

int a[] = {0,1,0,0,1};
int b[] = {0,1,0,0,1};
int c[] = {1,1,0,0,1};

b and c are

4条回答
  •  醉话见心
    2020-12-09 20:12

    If you mean

    int a[] = {0,1,0,0,1};
    int b[] = {0,1,0,0,1};
    int c[] = {1,1,0,0,1};
    

    then

    memcmp(a, b, sizeof(a)); /* returns zero for a match */
    memcmp(a, c, sizeof(a)); /* returns nonzero for no match */
    

提交回复
热议问题