could someone please explain this code and the output to me?
#include <stdio.h>
#include <unistd.h>
int main(void)
{
printf("one\n");
fork();
printf("two\n");
return 0;
}
Ouput:
Explanation:
fork() function is used in order to create new process (child process).
------------------------------------------------------------------------------
Commented code:
Code to copy:
//header files
#include <stdio.h>
#include <unistd.h>
// main function
int main(void)
{
// this print will normally print "One"
printf("one\n");
// fork function will create a new process
// the "two" statement will print twice,
// because of fork() function
fork();
printf("two\n");
// return
return 0;
}
--------------------------------------------------PLEASE UPVOTE-------------------------------------
Get Answers For Free
Most questions answered within 1 hours.