parameter passing in C function -



parameter passing in C function -

i have function written in c

findbeginkey(keylisttraverser, beginpage, beginkey, key1);

beginkey pointer before function invoking, , didn't initiate it, like

beginkey = null;

in findbeginkey() function, assign beginkey pointer, , seek print out current address of beginkey in function, works correct. when code returns function, seek print out address of beginkey again, shows 0x0.

why happen, , if want preserve address assigned in function, should do?

to pass value out of function have pass by reference rather by value case c functions. create parameter pointer type want pass out. pass value phone call & (address operand).

e.g.

findfoo(foo** beginkey);

and phone call it:

findfoo(&beginkey);

and in function:

*beginkey = 0xdeadc0de;

c function parameter-passing

Comments

Popular posts from this blog

web services - java.lang.NoClassDefFoundError: Could not initialize class net.sf.cglib.proxy.Enhancer -

Accessing MATLAB's unicode strings from C -

javascript - mongodb won't find my schema method in nested container -