Have you noticed that when the fifteen
program starts up, the entire screen is cleared? Compare that to the other programs before this, which just display the output directly after the command line.
The reason for this happening is shown in the greet()
function:
void greet(void)
{
clear();
printf("GAME OF FIFTEEN\n");
usleep(2000000);
}
Here we see that the first line called is the clear()
function. From the observed behaviour we might assume that this is clearing the screen. This is all happening after your own printf
message.
So what is actually happening is:
- Your program begins running.
- Prints out "abc\n".
- Calls
greet()
.
greet()
calls clear()
.
clear
clears the screen, including the message you just printed.
The reason you see your message in gdb
is that you are able to execute one command at a time, which gives you time to see the output. In normal operation it does exactly the sam thing, it just happens too quickly for you to see.