Hi,
If i am to have a function to return a pointer of an unknown type, is this the right prototype for it?
Code:void *function( void *one, void *two );
Hi,
If i am to have a function to return a pointer of an unknown type, is this the right prototype for it?
Code:void *function( void *one, void *two );
Yes. You are simply returning an address without any indication as to what type of data the address refers to.
Jason Deckard
Probably with something like this.
char *s = NULL;
char *blah1, *blah2;
s = function(blah1, blah2);
Something like that :) You will want to use a typecast since function() is returning a NULL pointer:Originally posted by dharh
Probably with something like this.
char *s = NULL;
char *blah1, *blah2;
s = function(blah1, blah2);
Code:s = (char *) function(blah1, blah2);
Jason Deckard
Im not sure thats necessary if you protoype it as a pointer.
> Something like that You will want to use a typecast since
> function() is returning a NULL pointer:
Slight correction here. It's not returning a NULL pointer, it's returning a VOID pointer. Null is a value of zero, meaning it points to nothing. A void pointer is a pointer who's type can be anything. Typecasting is not usually required in C when using void pointers. (Consider 'malloc'.)
Quzah.
Hope is the first step on the road to disappointment.
You are absolutely correct. Simply a typographical error on my part.Originally posted by quzah
> Something like that You will want to use a typecast since
> function() is returning a NULL pointer:
Slight correction here.
Jason Deckard
Typecasting a void * is actually -never- required in C... but C++
Callou collei we'll code the way
Of prime numbers and pings!