OK I'm just learning C with this book of Kernighan and Ritchie; I'm in the basics of the fourth chapter (functions stuff). The other day I came in curiosity with this function sleep(), so tried to use it like this:
#include <stdio.h>
#include <unistd.h>
int main(void)
{
printf(" I like cows.");
sleep(5);
return 0;
}
The problem is the output of the program, it looks like it does the sleep() first and then the printf(), in other words, it waits five seconds and then prints the string. So i thought, maybe the program gets to sleep() so fast that it doesnt let printf() have his work done like i want, that is print the string and then sleep.
So my question is, How can i show the string and then put the program to sleep? The compiler is GCC 3.3.5 (propolice) in OpenBSD 4.3.
PS I don't know how you put here the preprocessor lines correctly.