Fork()

Please someone!! I need use FORK() to do the code below run in three differents processes:

1- void primo(int nr1, int nr2)
2- {
3- int i, j, numero;
4- for(numero = nr1; numero <= nr2; numero++)
5- {
6- j=0;
7- for(i=nr1; i<=nr2; i++)
8- {
9- if((numero % i) == 0)
10- {
11- j=j+i;
12- }
13- }
14- if(j == (numero + 1))
15- {
16- printf("%d", numero);
17- }
18- }
19- printf("\n");
20- }

I don't do any idea how to do it!! If someone could explain how the FORK() works, how to use it make it divide a process like that code, I'll thank forever!! =P
1. fork() only works on unix-like systems, make sure you're not on Windows.
2. Try googling "unix fork example C++" or something, I guarantee you will get an example.
Topic archived. No new replies allowed.