Consider the following call to the variadic function execl():
execl("ls", "ls", "-l", (char *) NULL);
A variadic function is one that takes a variable number of arguments or arguments of varying types.
Whether the cast is required before the
cases like this is the source of some confusion. While we can often get away without the
cast, the C standards require it; failure to include it may lead an application to break
on some systems.
NULL is typically defined as either 0 or as
(void *) 0. (The C standards allow other definitions, but they
are essentially equivalent to one of these two possibilities.) The main reason casts are
needed is that
NULL is allowed to be defined as 0, so this is the case we examine ...