What is the output of this program? [code] #include<stdio.h> int main() { fork(); printf("123hoidap\n");

What is the output of this program?
Code:
   #include<stdio.h>
   int main()
   {
       fork();
       printf("123hoidap\n");
       return 0;
   }
A. the string “123hoidap” will print 1 time
B. the string “123hoidap” will print 2 times
C. the string “123hoidap” will print 3 times
D. none of the mentioned
 
Answer: b
Explanation: The “fork” system call creates a new process by duplicating the calling process. Hence the next statement is executed by two processes.
Output:
[root@localhost 123hoidap]# gcc -o san san.c
[root@localhost 123hoidap]# ./san
 

Tìm kiếm

Back
Top