Building a Function to work on Range of Array Values




This video tutorial explains how to create a function which works on range of array values using pointers in c++.
You will learn how to pass the array elements to the function using pointers in detail with examples.

source code for this tutorial

#include <iostream>

using namespace std;
void display(const int *start, const int *end);

int main()
{
    int numbers[] = {22,55,66,44,22,55,88,77,99};
    display(numbers+3,numbers+5);
    return 0;
}


void display(const int *start, const int *end){

    const int *ptr;
    for(ptr = start; ptr != end; ptr++){
        cout << *ptr <<endl;
    }

}

 
Back To Top