void pointer

J

janus

Hello All,

I am aware that void pointer (or generic pointer) could be use in
function arguments and as the return type of a function.

void * swap1(void * lpr1, void * lpr2,...);

Is there any other place it may be used? If yes, please give
examples.

Regards,
Janus
 
N

Nick

janus said:
Hello All,

I am aware that void pointer (or generic pointer) could be use in
function arguments and as the return type of a function.

void * swap1(void * lpr1, void * lpr2,...);

Is there any other place it may be used? If yes, please give
examples.

This smells slightly like a homework problem. But the answer is that it
may be used anywhere you are keeping or transferring a pointer without
dereferencing it. To and from a function is an obvious such place, but
inside a storage container of some sort is another.

Example:

char *p;
void *q = p;
char *w = q;

That's pointless, but you asked about "may", not "may usefully"...
 
J

janus

Nick,

I am not a student, I am just trying to learn C on my own. Thanks so
much.

Regards,
Janus
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,766
Messages
2,569,569
Members
45,042
Latest member
icassiem

Latest Threads

Top