Quote (irimi @ Sep 18 2012 10:11pm)
yes, the function's return type is a pointer. and yes, you're returning a pointer. but your code won't compile because you're returning the address of a variable on the stack. that's a huge no-no.
in C, you need to allocate the memory required to store the data that you want to manipulate (via malloc), and typically, you should never allocate memory and allow that memory to leave the scope of the function it was allocated in.
perhaps you should tell us what it is you're trying to do, and then we can tell you how far off you are from even beginning to attempt to do so.
Oh these are just practice questions I was going over. I was just trying to clarify what a pointer did and it's purpose.
The last question was just a practice question we were given and I didn't know the answer to.
So the above problem doesn't work because &y refers to the address, not the value, y is pointing towards?
God I miss java
This post was edited by lopelurag on Sep 18 2012 08:21pm