u have a new line in 2nd prog bt not in the st, that makes the difference.
when u do fork in 1st code, the "algo" is nt printed on the terminal,
rather it is in the stdout buffer oly, which gets duplicated in the forked
pr also. nd wen the prog terminates, whtver is ther in the buffer gets
printed on terminal.
bt in the 2nd code, due to new line, it gets flushed off before fork, nd so
the forkd pr doesn't print this.

On Fri, Nov 11, 2011 at 12:22 PM, rachel <[email protected]> wrote:

> main()
> {
>     printf("algo ");
>     fork();
>     // do anything
> }
> in this program, it is printing "algo" two times.
>
>
> main()
>  {
>     printf("algo \n");
>     fork();
>     // do anything
> }
> in this program, it is printing "algo" only once.
>
> when a fork() is done, processes gets doubled and the execution starts
> from the part of the program below the fork() command, am i correct ?
>
> Thanks in advance.
>
> --
> 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