hi i the following is a simple code with while 1, but when i execute it , first it should print the first line in printf and then sleep for 1 sec and then print the second line and it should keep on doing but here i don't get anything in the terminal and after few seconds suddenly everything is printed and then goes back to sleep . what is happening exactly i am not understanding .
int main(void)
{
while(1)
{
printf("hello before sleep");
sleep(1);
printf("hello after sleep");
}
}
but in the same code above if i use \n after every line in the printf it works fine as i expected . why is it so ?