Confusion in quiz question that may well be confusing other users.
I recently came accross a quiz that asked the output of void f(int * x) { x -= 5; } int main() { int k = 7; f(&k); printf("%d",k); } and says that the answer is 2(it'd be if instead of x-=5 we have *x-=5), when the answer is 7. the thing here is that even though x is a pointer, in C, every argument of a function is passed BY VALUE so if we directly assign some value to an argument, like in x-= 5 it will not change it outside the functions scope, you need to access the memory address of the pointer argument to be able to make changes to it. This needs to be like this even if you want to change the address of a pointer, then you need to take a pointer to a pointer as argument, and change the address of a pointer via dereference(i.e. * operator), like so void addOneToAddr(int ** addr) { *addr += 1; // *addr is pointer to int } and use it like int buf[] = {1,2,3,4}; int * bufptr = buf; // now bufptr points to address of buf[0] addOneToAddr(&bufptr); // now bufptr points to address of buf[1]