0
Implements the function void power_ref(int* x, int y)
which calculates the power of x
leading to y
. The result must be placed at the address indicated in the first parameter, changing its initial value.
I have something like this:
#include <stdio.h>
void power_ref(int* x, int y){
int result = (int) *x ^ y;
*x = result;
printf("result: %d", result);
}
What is your difficulty in exercise?
– Victor Stafusa
Because the
x
is a pointer and the function isvoid
? It would not be simpler and more natural to return the calculated value?– Victor Stafusa
is as they ask in the ex , the difficulty is with the Pointer because I do not know well how to use it
– Beatriz Ferreira
I have put what I have asked in the question above
– Beatriz Ferreira
You know how to do a function
int power(int x, int y)
? If yes, post it that based on it it is easy to do thepower_ref
.– Victor Stafusa
The
^
in C does not exponenciate. The^
in C is the XOR (or-exclusive). That’s not what you’ll need to use. You’ll need afor
.– Victor Stafusa
so that one is?
– Beatriz Ferreira
To make successive multiplications.
– Victor Stafusa