I am working with function pointer and strokes for a private project.
I have the following code (except for import):
typedef int (* intFunction) (int, int); Typedef Structure {int value; IntFunction func; } ValueFunc; Int addInts (int a, int b) {return a + b; } Int main () {ValueFunc vf; Vf.value = 3; Vf.func = and addInts; Int y = vf.func (vf.value, 4); Printf ("% i", y); Free (vf.func); Return 0; }If someone can explain why this is happening, then I highly appreciate it.
 You only need  free  which is dynamically allocated (For example, by using  calloc ,  malloc  or any work from that family). 
 You have never allocated memory, so you do not need to free them. And for a  free  function a random indicator is passing, it will misbehave. 
Comments
Post a Comment