Content covered: 

How many times the following code will print "techtud" ?

main(){
  p = fork();
  if(p > 0){
    fork();
    printf("techtud");
  }
  printf("techtud");
}

 

Hradesh @hradeshpatel
10 Jan 2017 11:24 pm

thks sir

priyanka gautam @priyankagautam
10 Jan 2017 11:43 pm

great sir.... thanku

Vivek Vikram Singh @vivek14
11 Jan 2017 05:43 pm
Techtud Admin @techtud
11 Jan 2017 05:48 pm

This is a nice example, Let's include it into preparation.

Shivesh Kumar Roy @shiveshroy
11 Jan 2017 10:02 pm

Thanks a lot pritam Prasun sir for such an awesome video, It basically cleared all the co-concepts related to fork() system call. I really appriciate your effort.

abhik roy @abhik2415
12 Jan 2017 06:38 pm

for the first fork() call i m getting the below warning, can you pls explain why this warning is coming.

"fork.c:33:4: warning: implicit declaration of function ‘fork’ [-Wimplicit-function-declaration]"

Sumit Verma @sumitverma
12 Jan 2017 06:47 pm

Working fine. Check:
https://ideone.com/Tx6Ozj

ynv vikas @vikasynv
17 Jan 2017 04:48 pm

please add this line to your code. #include  <sys/types.h>

Sumit Verma @sumitverma
17 Jan 2017 04:51 pm

Thanks for your suggestion. But it is just a part of code to explain the fork concept, So main function is sufficient.