rand() not generating random numbers after modulo operation

后端 未结 8 2019
一向
一向 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:51

    Yes, because you dind't "initialize" the rand(). Try to do something like that srand (time(NULL)) ;

    You have also to include time.h

提交回复
热议问题