execl()'ing batch files in DOS

Guy Harris guy at auspex.auspex.com
Fri May 19 02:57:02 AEST 1989


>	execl("\command.com", "tryit.bat", NULL);

Oh, and as long as you're fixing this statement as per the other
comments, change "NULL" to "(char *)NULL".  NULL may be defined, at
present, so as to make the code work without the cast, but the code
isn't correct without it; put the cast in anyway, so that:

	1) you get into the habit of doing it, so that your code works
	   on systems where NULL *isn't* defined so as to make it work;

	2) your code is protected against changes to the environment
	   that might make it no longer work.

(No, function prototypes won't fix this case, since "execl" needs a
prototype like:

	int execl(char *, ...);

and the NULL matches the "...", so the compiler has no idea that an
actual argument of type "char *" is needed here.)



More information about the Comp.lang.c mailing list