We currently learn about pointers in combination with arrays in C/C++ and have to implement some function, for which we have a given function call. The objective is to print out the array values by calling the function with the array adress. The output is not what was expected.
I tried printing the the array values with & and * as well as with none of those.
void ausgabe1D_A(double (*ptr1D)[4]){
int i{0};
for (i = 0; i < 4; i++)
std::cout << *ptr1D[i] << " ";
}
int main()
{
double ary1D[4] = {1.1, 2.2, 3.3, 4.4};
ausgabe1D_A(&ary1D);
}
I expected the output to be:
1.1 2.2 3.3 4.4
Instead I got:
0x61fdf0 0x61fe10 0x61fe30 0x61fe50 (with and without &)
1.1 9.09539e-318 0 0 (with *)
EDIT: Sorry if that wasn't clear, but we have to call the function with &ary1D. We are trying out different ways and your ways are coming up in the exercise in following functions but for now we need it with the &-Operator.
