rand() not generating random numbers after modulo operation

后端 未结 8 1997
一向
一向 2020-12-07 04:43

I\'m taking a C refresher and took on a board game as an exercise. The board game is \"Game of the Generals\" and is pretty much like chess as it uses pieces with ranks on a

8条回答
  •  囚心锁ツ
    2020-12-07 04:46

    you should use srand() to seed your random generator.

    A common random seeding is srand ( time(NULL) );

提交回复
热议问题