I am trying to call the fork() system call. It works quite fine until I don't use printf method in the code. My code is as follows.
Platform: Linux Language: Pure C
#include <sys/types.h>
#include <unistd.h>
#include <stdio.h>
pid_t fork(void)
main()
{
int pid;
pid = fork();
if(pid == 0)
{
// printf("This is child \n");
}
else {
// printf("This is parent \n");
}
}
As I said earlier it work quite fine but removing comment sign from two printf methods creates lots of problems.
Any idea why fork() method not allowing to use printf? What is the solution?
Thanks!