I am trying to implement a function that takes an array, calculates 1/X for each element, and returns the resulting array.
However, I have an issue when trying to determine the size of each array. sizeof(X) / sizeof(X[0])
does not correctly calculate the array size, and instead outputs 0.
double* MyFunction(double X[]) {
std::cout << "arraySize of x: " << sizeof(X) / sizeof(X[0]);
double A[100] = {};
for (int i = 0; i < sizeof(X) / sizeof(X[0]); ++i) {
A[i] = 1 / X[i];
}
return A;
}
What am I doing wrong?