#include <iostream>
using namespace std;
int binarySearch(int inArray[], double targetVal)
{
int lowIndex = 0;
int upIndex = (sizeof(inArray)/sizeof(inArray[0]));
int middleIndex = (lowIndex + upIndex) / 2;
cout << sizeof(inArray) << endl;
cout << inArray[3] << endl;
// cout << upIndex << endl;
}
int main()
{
int a[4] = {0 , 1 , 3, 5};
cout << sizeof(a) << endl;
// cout << sizeof(a)/sizeof(*a) << endl;
binarySearch(a , 3);
}
This is the relevant code. In main(), sizeof(a) outputs 16. in binarySearch(), sizeof(inArray) outputs 8. Could someone explain to me why there isa difference? Array a should be identical to inArray?