im trying to do this exercise where i have to create a number guessing game. basically let user enter a number and the program will either say too high or too low until the user guess the right number. i think i got the guessing part okay. but i would like to let the user decide if he wants to keep continuing the game or not, and that part doesnt seem to work. could someone help?
actually i dont really understand that line : srand(time(0)), i just saw it on text book that it could give random number. and what is the difference with the other lines?
What I think Kenner is getting at is this. The time function returns a value of type time_t, this type is either a 32bit or 64bit integer (32bit is deprecated due to the integer value rolling over in the year 2038).
The function srand, takes an unsigned int as its parameter. When you pass the time_t value into srand it is implicitly converted to the required type for the function, this conversion may result in data loss i.e. 64bits do not fit into 32bits so half the bits are lost. Your compiler should warn you of such possible data losses.
static_cast just dose an explicit conversion of the same data types. It in no way prevents data loss, but does stop the compiler warning of it.