#include <stdio.h>
#include <string.h>
#include <sys/types.h>
#define MAX_COUNT 200
#define BUF_SIZE 100
void main(void)
{
pid_t pid;
int i;
char buf[BUF_SIZE];
fork\(\);
pid = getpid\(\);
for \(i = 1; i <= MAX_COUNT; i\+\+\) \{
sprintf\(buf, "This line is from pid %d, value = %d\\n", pid, i\);
write\(1, buf, strlen\(buf\)\);
\}
}
if i execute the code the process would be link
Parent Child
main() main()
{ {
fork(); fork();
pid=.. pid=...
} }
but ,do both processes execute the while loop seperately
can i get the result like that
parent 1 ...............200
child 1...............200