Basic and Advance C Question:
Download Questions PDF

I came across some code that puts a (void) cast before each call to printf. Why?

Answer:

printf does return a value (the number of characters printed, or an error code), though few programs bother to check the return values from each call. Since some compilers (and lint) will warn about discarded return values, an explicit cast to (void) is a way of saying ``Yes, I've decided to ignore the return value from this call, but please continue to warn me about other (perhaps inadvertently) ignored return values.'' It's also common to use void casts on calls to strcpy and strcat, since the return value is never surprising.

Download C Programming Interview Questions And Answers PDF

Previous QuestionNext Question
If NULL and 0 are equivalent as null pointer constants, which should I use?I have seen function declarations that look like this