My that logic is incorrect and I am sorry for that .
fine it's buffer flushing issue not that.

On 31 October 2012 15:35, Rahul Kumar Patle <[email protected]>wrote:

> @shivam: but when i replace
> printf("Hello"); by printf("Hello\n");
> it works correctly.. can you justify this by your logic..
>
>
> On Wed, Oct 31, 2012 at 1:07 PM, Shivam Rohilla <
> [email protected]> wrote:
>
>> Yes it will print 30+ times.
>> fork() --> it's create the the child process which copie's the address
>> stack of the parent process.
>> now when you will do fork();
>> look 1st iteration --> it wil break; ( if parent process scheduled 1st by
>> the kernel )
>> when 2nd iteration --> it will again fork in child process. and will
>> print hello once and dan goes to parent dan break.
>> when 3rd iteration -->  it will fork again and print hello twice and dan
>> break
>> when 4th iteration --> it will again fork and prnt hello 4 times i.e.
>> hello once by iteration and dan fork child will start process from start
>> and dan print hello 3 more times and dan parent will schedule and dan break.
>> and so on...
>>
>> On 31 October 2012 11:49, tendua <[email protected]> wrote:
>>
>>> \n also flushes the standard output buffer. If it is not present, it is
>>> possible that you have previously entered data in it. Flushing also means
>>> it forces printf to print on the screen as soon as \n is processed.
>>> Otherwise it is buffered output and you can never predict how long would OS
>>> buffer your output and when precisely it chooses to actually print.
>>>
>>> --
>>> You received this message because you are subscribed to the Google
>>> Groups "Algorithm Geeks" group.
>>> To view this discussion on the web visit
>>> https://groups.google.com/d/msg/algogeeks/-/cNFex4s9a8UJ.
>>>
>>> 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.
>>
>
>
>
> --
> Thanks and Regards:
> Rahul Kumar Patle
> M.Tech, School of Information Technology
> Indian Institute of Technology, Kharagpur-721302, 
> India<http://www.iitkgp.ac.in/>
> Mobile No: +91-8798049298, +91-9424738542
> Alternate Email: [email protected]
> [image: 
> Linkedin]<http://www.linkedin.com/profile/view?id=106245716&trk=tab_pro>
> [image: Twitter] <https://twitter.com/rahulkumarpatle>
> <https://www.facebook.com/rkpatle>
>
>  --
> 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