3
In the srand’s handbook man srand
says srand has as a parameter a unsigned int
, but when using without cast the compiler does not complain. It has some possibility of going wrong if not using with cast (unsigned int)
? If yes, what possible errors ?
An example, comparing the two lines of code below:
srand(time(NULL));
srand((unsigned int)time(NULL));
Compile with Warning connected. Warning It’s an error that allows you to compile but it’s still a mistake. It is an error that you don’t have to worry about in any compilation, but when you finish the program it is an error that cannot exist.
– Maniero
@Bigown I always compile using
gcc -Wall -pedantic -std=c99 -o saida entrada.c
and never leave my codes finished with Warning, except in very extreme cases. But in this case, the compiler did not accuse any Warning, that’s what I meant in "...but when using without cast the compiler does not complain...", complains, in case, it would be Warning, sorry not to have explained this.– ViniciusArruda