small question

B

Bill Cunningham

You might also consider trying to *understand* how it's done.

memset() takes as its first parameter a void* and that mean to pass any
type since void is the generic type with the & in front of it. And that's
how it's done.

Bill
 
K

Keith Thompson

Bill Cunningham said:
memset() takes as its first parameter a void* and that mean to pass any
type since void is the generic type with the & in front of it. And that's
how it's done.

Since you've shown *some* understanding here, I'll reply.

Rather than saying that void is the generic type (it really isn't),
it's better to say that void* is the generic pointer type.

Applying unary & to the name of an object gives you a pointer to that
object, which can be passed as an argument to a function with a
parameter of type void*.

The phrase "and that mean to pass any type since void is the generic
type with the & in front of it" is, to be blunt, a bit incoherent; I
can't tell from it whether you really understand or not, or if not,
what your remaining misconceptions might be.
 
K

Kenny McCormack

Keith Thompson said:
I've told you this before.

And it was worth the same then as it is now (nothing).

Do you honestly think anyone gives a crap about anything you say?
(no matter how many times you say it)

--
(This discussion group is about C, ...)

Wrong. It is only OCCASIONALLY a discussion group
about C; mostly, like most "discussion" groups, it is
off-topic Rorsharch revelations of the childhood
traumas of the participants...
 
N

Nick Keighley

please don't top post I've rearranged your post

hints is not a pointer,

where did I say it was?

but &hints is a pointer.  However, &hints is not a variable, so you
can't assign to it.  

where did I say it was?
 
B

Bill Cunningham

/*
** Here's the long way:
*/
struct addrinfo hints;

int main()
{
struct addrinfo *pointer = &hints;

memset(pointer, '\0', sizeof hints);

Ok now that's familiar to me. Pointer points to an assigned address. So
memset(&hints,'\0',sizeof hints); is a shortcut then? I didn't know you
could shortcut this kind of thing.

Bill
 
B

Bill Cunningham

pete said:
/*
** Here's the long way:
*/
struct addrinfo hints;

int main()
{
struct addrinfo *pointer = &hints;

memset(pointer, '\0', sizeof hints);

Yes that helps alot!

Bill
 

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
474,432
Messages
2,571,680
Members
48,796
Latest member
Greg L.

Latest Threads

Top