Point Pointers to Arrays - C Pointer

C examples for Pointer:Array Pointer

Description

Point Pointers to Arrays

Demo Code

#include <stdio.h>

int arraySum (int array[], const int n)
{
    int sum = 0, *ptr;
    int * const arrayEnd = array + n;

    for ( ptr = array; ptr < arrayEnd; ++ptr)
    {/*w ww . j  a v  a 2  s . com*/
        sum += *ptr;
    }

    return sum;
}

int main (void)
{
    int arraySum(int array[], const int n);
    int values[10] = {3, 2, -1, 3, 5, -1, 8, 9, 1, -5};

    printf ("The sum is %i\n", arraySum (values, 10));

    return 0;
}

Result


Related Tutorials