warning C4244: 'argument' : conversion from 'time_t' to 'unsigned int', possible loss of data — C++

前端 未结 4 1915
栀梦
栀梦 2020-12-13 19:36

I made a simple program that allows the user to pick a number of dice then guess the outcome... I posted this code before but with the wrong question so it was deleted... no

4条回答
  •  青春惊慌失措
    2020-12-13 19:59

    This line involves an implicit cast from time_t which time returns to unsigned int which srand takes:

    srand ( time(NULL) );
    

    You can make it an explicit cast instead:

    srand ( static_cast(time(NULL)) );
    

提交回复
热议问题