pointers - Passing point as a reference in C? -
in c, want pass pointer function coded following,
node* list // contains linked list of nodes void function (node* list){ /*whatever here, want make sure modify original list, not local copy. + how pass original pointer 'list' function i'm working on same variable? */ } [edit]
i clarify few things here,
i have void function takes struct argument,
void function (struct value arg){ } and in struct, i'm defining 1 of internal variables as,
node* list-> list; so in function, if like,
arg->list am accessing original list variable?
to answer edit:
no, passing structure value, function contains copy of structure. if don't return structure in function , grab called function from, lost.
keep in mind c not pass reference. instead simulated passing pointer. instead this:
void function (struct value* arg) { .... } and modify original structure.
Comments
Post a Comment