@lip The problem was indeed that rand() returned a zero at some moment. And therefore default_random_engine generator(0);
aborted.
The solution was quite simple: Create a function that checks that rand() it is not a zero:
int rand0()
{
int dummy = rand();
while(dummy==0)
{
dummy = rand();
}
return dummy;
}
And then: default_random_engine generator(rand0());