rand() % n
will never give you a number larger than RAND_MAX. RAND_MAX is the range of the numbers generated by rand().
If you use a value of n larger than RAND_MAX, you will loop forever after you draw the first RAND_MAX numbers. Simply, there's no numbers left to draw.
You need to improve your solution to be able to generate larger numbers, or use something better like shuffling a larger list of numbers.
Your algorithm has many issues, but an immediate simple fix would be:
rnd_number = (rand() * (RAND_MAX + 1) + rand()) % n;
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…