casts to (void)

Keith Pilotti @shine pilotti at telesoft.UUCP
Wed Jul 31 18:25:41 AEST 1985


In article <> mjs at eagle.UUCP (M.J.Shannon) writes:
>>     Why should a cast to (void) be necessary in a statement like
>>  (void) printf("foo\n");
>>...
>The cast is necessary because printf() returns a value.
>...

    The use of (void) also points out the fact that the programmer
    *intentionally* is ignoring the return value of the function.

    At the very least it is useful documentation.

    /+\ Keith
    ________________________________________________________
    KEITH F. PILOTTI -- TeleSoft         (619) 457-2700 x172
                        10639 Roselle St, SanDiego, CA 92121

        (UUCP) {decvax,ucbvax}!sdcsvax!telesoft!pilotti
        (ARPA) Pilotti at UCSD



More information about the Comp.lang.c mailing list