9

I have seen this piece of code on one of the forums and I'm finding it difficult to find the output of the given code. I'm really confused how do i go solve this particular line??

 fork() && fork() || fork();
#include <stdio.h>
#include <unistd.h>

int main()
{
    fork();
    fork() && fork() || fork();
    fork();

    printf("forked\n");
    return 0;
}
Daniel Fischer
  • 181,706
  • 17
  • 308
  • 431
Amit Singh Tomar
  • 8,380
  • 27
  • 120
  • 199
  • Relevant question here: http://stackoverflow.com/questions/26716255/why-does-this-program-print-forked-4-times/26716300?noredirect=1 – gsamaras Nov 04 '14 at 15:20

0 Answers0