rand()%1 + 1 isn't very random, being guaranteed to be constantly 1.

Search the FAQ on random numbers.