in function printLong i'm passing void pointer e so does the cast (long) e makes that adress of e? how come i'm getting a value of data and not the address printed?
no. It casts the pointer to a long int. If you want to get the address of e, use &e instead. But e is already the address of a function... i see no point in getting the address of a argument because it is on the stack.
So basically I guess you might have some misunderstanding on functions.A function name is not like a var name:
- var_name has a value and you use &var_name to get the address
- function_name itself has the value of the address the function
implementation and &function_name would return the same
value(the same address).
UPDATE:
I call f(q->data[i]); to get to printLong (void* e) - so shouldn't e be pointing to q->data[i] ?
In C, function arguments are passed by value. The value of q->data[i] is passed to printLong() so the argument e would have the same value(the same address) as q->data[i]. so e is a copy of q->data[i]