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
  • 178,696
  • 16
  • 303
  • 427
Amit Singh Tomar
  • 8,130
  • 25
  • 109
  • 193
  • 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