Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C Programming > void pointer

Reply
Thread Tools

void pointer

 
 
janus
Guest
Posts: n/a
 
      12-26-2009

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
 
Reply With Quote
 
 
 
 
Nick
Guest
Posts: n/a
 
      12-26-2009
janus <(E-Mail Removed)> writes:

> 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"...
--
Online waterways route planner: http://canalplan.org.uk
development version: http://canalplan.eu
 
Reply With Quote
 
 
 
 
janus
Guest
Posts: n/a
 
      12-27-2009
Nick,

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

Regards,
Janus

On Dec 26, 12:59*pm, Nick <(E-Mail Removed)> wrote:
> janus <(E-Mail Removed)> writes:
> > 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"...
> --
> Online waterways route planner:http://canalplan.org.uk
> * * * * * *development version:http://canalplan.eu


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
What is the difference between void proba(); and void proba(void); ??? PencoOdStip@gmail.com C++ 1 05-23-2007 07:12 PM
Conversion from 'void*' to pointer to non-'void' requires an explicit cast Hakirato C++ 4 10-05-2006 04:02 PM
what is the difference, void func(void) and void fucn() noblesantosh@yahoo.com C Programming 5 07-22-2005 04:38 PM
"void Method()" vs "void Method(void)" Ollej Reemt C++ 7 04-22-2005 03:47 AM
`void **' revisited: void *pop(void **root) Stig Brautaset C Programming 15 10-28-2003 09:03 AM



Advertisments