Geoff Harper wrote: > Can someone explain where C's printf sends its data to, and how it >arrives at selecting the destination? Jim Wowchuk <[log in to unmask]> wrote: >Two things you might want to try with your sample code > >1) flush the printf buffers using fflush() function. Good idea. >2) terminate with an _exit() rather than the (implied) exit() Bad idea. The implied exit() *is* flushing the stdio buffers, otherwise it wouldn't appear at all, instead of just out of order. Calling _exit() traditionally *doesn't* flush the stdio buffers, it just kills the process without doing any C Library cleanup. It's normally used in situations like this: printf("forking off a child process"); if (fork() == 0) { /* Setup child's enviroment */ if (error) { /* Oops... something failed. */ _exit(1); } execv(...); } If exit() were used instead of _exit() in this example, it could result in the message being printed twice, once in the parent process and once in the child process. Ross Ridge -- l/ // Ross Ridge -- The Great HTMU +1 519 883 4329 [oo][oo] [log in to unmask] http://csclub.uwaterloo.ca/u/rridge/ -()-/()/ db //