ne555 why Do you say one(int k){*a=k;} doesn't work?It pases the value of an integer variable to the containing value of a pointer.Am i wrong? I don't know if it is safe(although it looks like) but it works to me.
It pases the value of an integer variable to the containing value of a pointer.Am i wrong?
The problem is 'a' doesn't point to anything. You can't assign a value to what the pointer points to unless it actually points to a variable. Otherwise you're just writing the value to random memory -- causing heap corruption and possibly a program crash.