I have a srand(time(NULL))
at the beginning of the execution, then I am doing
*pos_x = (rand() % HEIGHT);
*pos_y = (rand() % WIDTH);
to generate random numbers.
This works fine when I run my program manually, but when I lunch my program with this script :
#!/bin/bash
i="0"
team_number="0"
while [ $i -lt 30 ]
do
./lemipc `pwd` team_number
i=$[$i+1]
if (( $i % 10 == 0 ))
then
team_number=$[$team_number+1]
fi
echo "create process $i"
usleep 10000
done
I always get the same numbers for all the processes.
I even tried to add a usleep to fix this but it still doesn't work. I get this for exemple :
97 51
create process 1
97 51
create process 2
97 51
create process 3
97 51
where 97 is pos_x and 51 pos_y.
Have an idea why ?