-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.

Community
  • 1
  • 1
Whoami
  • 13,930
  • 19
  • 84
  • 140
  • Similar question http://stackoverflow.com/questions/689677/casting-unused-return-values-to-void – int Mar 20 '12 at 15:07

1 Answers1

4

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

cnicutar
  • 178,505
  • 25
  • 365
  • 392
  • 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." – David Schwartz Mar 20 '12 at 15:11