if和else不是只能进入一个么?那么下面的程序中是怎么进入了if又进入了else呢?求高手解答!

#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <unistd.h>

void main()
{
pid_t pid1,pid2;
char ch1,ch2,ch3;
pid1=fork();
ch1='b';
ch2='c';
ch3='a';

if(pid1<0){
fprintf(stderr,"Fork 1 Failed");
exit(-1);
}
else if (pid1==0){
printf( "%c\n",ch1 );
}
else{
wait(NULL);
printf( "%c\n",ch3);
exit(0);
}
pid2=fork();

if(pid2<0){
fprintf(stderr,"Fork 2");
exit(-1);
}
else if (pid2==0){
printf( "%c\n",ch2 );
}
else{
wait(NULL);
printf( "%c\n",ch3);
exit(0);
}
}

这种用法的专业术语叫“嵌套”,你所说的是if语句的嵌套,不仅if语句有嵌套,循环语句也有嵌套。
温馨提示:答案为网友推荐,仅供参考