really simple array

Nov 30, 2016 at 4:14pm
how do you create a function that passes in an array by value and the subscript and returns the value of the array at that subscript.
Nov 30, 2016 at 6:10pm
What, specifically, are you having trouble with?
Nov 30, 2016 at 8:01pm
1
2
3
4
5
6
7
8
9
10
11
12

/*    Assuming the array contains integers:    */


int getAt( int Array[], int subscript )
    {
    return Array[ subscript ];

    }
        /*    getAt()    */



NOTE: This is a very dangerous function! The variable subscript could reference to a position outside of the bounds of the array! This function doesn't know the dimensions of the array.
Topic archived. No new replies allowed.