The problem is because of \n in the prnintf statement. When new line is
there in first printf it flushes the standard buffer and so in child the
output of printf is not present in second program.
*Muthuraj R
IV th Year , ISE
PESIT , Bangalore*



On Sat, Aug 13, 2011 at 9:29 PM, Ankur Khurana <[email protected]>wrote:

>
> aren't two programs same ? and scheduling of two forked and parent process
> is prcoessor dependent. You dont have a say in it.
>
> On Sun, Aug 14, 2011 at 1:21 AM, thanu moorthy <[email protected]>wrote:
>
>> #include<stdio.h>
>> #include<unistd.h>
>> int main()
>> {
>>   int return_value;
>>   printf("forking process");
>>   fork();
>> printf("hello\n");
>> return 0;
>>
>>  }
>>
>> in the above program the output is
>>
>> forking processhello
>> forking processhello
>>
>> but in the below prog
>>
>>
>>   include<stdio.h>
>> #include<unistd.h>
>> int main()
>> {
>>   int return_value;
>>   printf("forking process\n");
>>   fork();
>> printf("hello\n");
>> return 0;
>>
>>  }
>> the output is
>> forking process
>> hello
>> hello
>>
>> why its so ??
>>
>> --
>> by $THANU$
>>
>>  --
>> You received this message because you are subscribed to the Google Groups
>> "Algorithm Geeks" group.
>> To post to this group, send email to [email protected].
>> To unsubscribe from this group, send email to
>> [email protected].
>> For more options, visit this group at
>> http://groups.google.com/group/algogeeks?hl=en.
>>
>
>
>
> --
> Ankur Khurana
> Computer Science
> Netaji Subhas Institute Of Technology
> Delhi.
>
>  --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to
> [email protected].
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.

Reply via email to