> have an actual algorithm that sorts the elements in descending order.
you were not asked to sort, you were asked to reverse
if the input is {42, 13, 54} the output would be {54, 13, 42}
> The function should return a pointer to the new array
that's a can of worms, so I would consider a bad exercise
If you can't use std::vector and don't know (or don't want to deal) with dynamic memory allocation then do something like
1 2 3 4 5
|
int *reverseArray(const int array[], int size){
static int reversed[100] = {}; //blind trust
//your reverse algorithm
return reversed;
}
|
About your code, you have some glaring conceptual errors
it seems that you don't understand functions parameters, return values, or scope
variables declared inside a function are local to that function, `pointer' in reverseArray() has no relationship with `pointer' in main()
About your algorithm, well you are doing nothing, you are not reversing but just copying
don't know if it was because you didn't understood the question, you have issues coding or you have no idea how to do it
try to write a pseudocode.