-1

Possible Duplicate:
casting unused return values to void
Need for prefixing a function with (void)
Casting function returns to void

Have seen in quite few places that while invoking the function why do we explicitly the return type of the function ? ex:

(void) myhostnames ( char * something); 

What is use of this (void), and how it differs from not using the same ? Kindly clarify.

1

1 Answer 1

4

Perhaps the function returns something and to prevent warnings from the compiler / errors from lint, the caller explicitly "throws" away the return.

Sign up to request clarification or add additional context in comments.

1 Comment

It's a way of the programmer saying to anyone who reviews this code (whether human or machine), "I know that this function returns a value and in this case the right thing to do is ignore that value. I'm calling this function for some reason other than to get its return value."

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.