#include <stdio.h>
#include <unistd.h>
int main()
{
int id;
printf("here comes the date.\n");
if (id = fork() == 0) {
printf(「%d」, id);
printf ("PID is %d and ID is %d\n", getpid(),id);
execl ("/bin/date", "date", 0);
}
printf ("that was the date.\n");
}
OUTPUT:爲什麼id變量1的輸出?
here comes the date.
that was the date.
PID is 1414 and ID is 1
Tue Feb 10 14:03:02 PST 2015
這是因爲[運算符優先級](http://www.difranco.net/compsci/C_Operator_Precedence_Table.htm):'='的優先級低於'==' – whoan 2015-02-10 22:34:53