It's sort of like joehms22 said, but it may not work using newlines alone. The printf() function is to stdout, which is buffered by default, and not output until flushed. A newline will not necessarily flush the output. So, do this instead:
#include<stdio.h>
main()
{
printf("welcome to\n");
fflush(stdout);
fork();
printf("DaniWeb Discussion\n");
fflush(stdout);
}
Note that stderr is not buffered. All output to stderr is output immediately, so this will also work:
#include<stdio.h>
main()
{
fprintf(stderr, "welcome to\n");
fork();
fprintf(stderr, "DaniWeb Discussion\n");
}
rubberman
Posting Virtuoso
1,559 posts since Mar 2010
Reputation Points: 277
Solved Threads: 178