what does fork() do in c.? Is it same as fork operation in OS ?
What is the o/p of following program ?

#include<stdio.h>
   main()
     {
       int i=0;
       fork();
       printf("%d",i++);
       fork();
       printf("%d",i++);
       fork();
       wait();
     }

Recommended Answers

All 2 Replies

See this thread for an example of how to use fork() As for what fork() does -- you can read this man page

thankx for reply.

actually i am unable to understand the working of fork and wait in a c program and futher how fork() and wait() calls affect the output.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.