The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > High Level Programming
Google UNIX.COM



Thread: Fork and \n
View Single Post in UNIX Forums - Click on the Thread or Permalink to View Entire Thread -->
  #1 (permalink)  
Old 05-15-2008
xyz123456 xyz123456 is offline
Registered User
 

Join Date: Apr 2008
Posts: 4
Smile Fork and \n

Hi,
I wrote a simple program for understanding the fork command. The code is as below
Code:
int main(void)
{
	fork(); printf("hi 1 \n");
	fork(); printf("hi 2 \n");
	fork(); printf("hi 3 \n");
}
I am getting a variation in the number of times the printf is called if i remove the \n from each of the printf statements . Can anyone explain me why this is happening.

Thanks in Advance,

bye.

Last edited by Yogesh Sawant; 05-15-2008 at 11:30 PM. Reason: added code tags
Reply With Quote
Forum Sponsor