why have two different results in the two program with c

#include<stdio.h>
int main()
{
printf(“hello world”);
fork();
return 0;
}
the output result is hello world hello world(appears two times)
#include<stdio.h>
int main()
{
printf("hello world
");
fork();
return 0;
}
the output result is hello world(only one time)

Hmm, I suspect this is the question your lecturer asked you to answer, no? :wink:

no,this question is in the book borrowed from the library

Read up on what happens to file descriptors when a process forks.