I am using gcc compiler on linux.
When I run this code (Notice"\n" is not present after hello world in printf)
#include<stdio.h>
#include<unistd.h>
#include<sys/types.h>
int main()
{
printf("Hello world");
fork();
}
I GET THIS OUTPUT: Hello worldHello world
On the other hand When I run this code (Notice"\n" is present after hello world in printf)
#include<stdio.h>
#include<unistd.h>
#include<sys/types.h>
int main()
{
printf("Hello world\n");
fork();
}
I GET THIS OUTPUT: Hello world
Can someone describe in detail that, why omitting or leaving "\n" prints "Hello world" twice?