I am trying to pass a queue to another function in c in order to make some operations on it, I’ve tried to send it’s reference and put in a pointer in the function arguments but that doesn’t make sense!
here’s what I did:
this is the caller:
G = my_job(&qu, inducing_cell, target_cell, G, vertices_number, cells_number);
this is the function:
graph* my_job(Queue *qu, Position inducing_cell, Position target_cell, graph* G, unsigned long vertices_number, unsigned long cells_number) {}
You need to pass in the address of a variable to a
Queuestruct.So as follows:
Or you can create a pointer to a
Queueand pass that in:If you want to pass in a pointer to alter what it points to and see the changes when the function returns, you’ll need to pass in a
Queue**because a pointer is passed by value, ie it’s copied into the function. So if you change what it points to inside, that change is not seen when the function returns.