Does anyone know why if i put a printf just before a delay it waits until the delay is finished before it prints de message?
Code1 with sleep():
int
When you call printf, you don't print anything until really necessary: until either the buffer fulls up, or you add a new line. Or you explicitly flush it.
So, you can either do
printf("Something\n"); delay();
or
printf("Something"); fflush(stdout); delay();