I have a small problem with this:
{
printf ("abc");
execl("./prog","prog",NULL);
}
All works fine, but why does execl
just run before printf
? Could someone help me?
I have a small problem with this:
{
printf ("abc");
execl("./prog","prog",NULL);
}
All works fine, but why does execl
just run before printf
? Could someone help me?
The printf
actually does run first, however it's output is buffered.
You can flush the buffer either by adding a newline (\n
) to the end of the string or by calling fflush(stdout)
:
printf("abc\n");
Or:
printf("abc");
fflush(stdout);