wen u write something in printf, its 1st stored in the stdout buffer, and then wen buffers gets filled up, it goes to std output, u can forcly flush it by using a fflush(stdout) api aftr ur printf st, or by putting a new ln..
On Fri, Nov 11, 2011 at 12:49 PM, rachel <asret...@gmail.com> wrote: > oh, so what you want to say is that when '\n' is not there in print > command and then it is stored in stdout buffer unless it receives a '\n' > and executes only in the end if '\n' is not received. > > thanks rahul :) > > > On Fri, Nov 11, 2011 at 12:31 PM, rahul vatsa <vatsa.ra...@gmail.com>wrote: > >> 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 <asret...@gmail.com> 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 algogeeks@googlegroups.com. >>> To unsubscribe from this group, send email to >>> algogeeks+unsubscr...@googlegroups.com. >>> 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 algogeeks@googlegroups.com. >> To unsubscribe from this group, send email to >> algogeeks+unsubscr...@googlegroups.com. >> 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 algogeeks@googlegroups.com. > To unsubscribe from this group, send email to > algogeeks+unsubscr...@googlegroups.com. > 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 algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.