3 ms·
This had better not be a homework problem. The lines "Line number 2 before execl" and "Line number 1 before execl" will not be printed on most systems because
by cperciva 18y ago
This had better not be a homework problem.
The lines "Line number 2 before execl" and "Line number 1 before execl" will not be printed on most systems because most systems default to line-buffering (when writing to a terminal) or fully buffering (otherwise) output.
The lines "... after execl" will not be printed if execl succeeds, because execl does not return if it succeeds.
Other bugs: You're not checking the return status of execl; you've declared main incorrectly; you need to #include <unistd.h> and <stdlib.h> if you're going to use execl and exit; you should pass a terminating NULL to execl, not 0 (the C compiler will coerce 0 to a pointer, but NULL is not guaranteed to be (void *)0).
- parenthesis 18y agoI thought 'the' standard said that 0 used in pointer contexts is interpreted by the compiler as a null pointer, even if the machine's representation of a null pointer is not 0.
- cperciva 18y agoI'm sure there is a standard which says that... but the nice thing about standards is that there are so many to choose from. :-) It's not something which you should rely upon.
- chanux 18y agoThanks for the informative answer. I need to look in to deep in the subject I guess.