1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

arrays and pointers

Discussion in 'C' started by ahmed vali, May 23, 2011.

  1. ahmed vali

    ahmed vali New Member

    Joined:
    May 23, 2011
    Messages:
    1
    Likes Received:
    0
    Trophy Points:
    0
    i need to check a program..
    take two arrays A and B,now write function that if every element of A is equal to its corresponding element in array B.the function must accept two pointer values and return a boolean
     
  2. DRK

    DRK New Member

    Joined:
    Apr 13, 2012
    Messages:
    44
    Likes Received:
    3
    Trophy Points:
    0
    Code:
    bool compareArrays(int *arrayA, int *arrayB, int arraySize)
    {
        int i;
        for (i = 0; i < arraySize; i++)
        {
            if (arrayA[i] != arrayB[i])
            {
                return false;
            }
        }
        return true;
    }
     

Share This Page