+ 8
So, in this code did the address of pointer k become -5?
#include <stdio.h> void func(int* x){ x-=5; } int main() { int k=7; func(&k); printf("%d",k); return 0; }
4 Respostas
+ 3
Nothing really happens. x in func had the address of k and then contains the address of 5 bytes before that. However, you never use it so it doesn't have any lasting effect as x's value is a local and not returned.
+ 4
John Wells doesn't x have 5 bytes * sizeof(int) value in func ?
+ 2
func() was not return int or pointer.
first:void must be -> int or returnable value.
second: func(){... return x;}
third: k=func(&k)
and then you take response from program.
+ 2
Baptiste E. Prunier yes, I forgot to look at the type of x so likely 20 bytes before k.