C89 / C90 (usually, but incorrectly, called "ANSI C") has an "implicit int " rule. If you call a function without a visible declaration, the compiler will effectively create an implicit declaration, assuming that the function takes type arguments that appear in the call and returns an int .
The time function takes an argument of type time_t* and returns a value of type time_t . Therefore, when calling
time(NULL)
without a visible declaration, the compiler will generate the code as if it took an argument of type NULL (which is likely to be int ) and returns an int result. Considering,
srand(time(NULL))
the value returned by time(NULL) will then be implicitly converted from int to `unsig
If int , time_t and time_t* all, say, 32 bits, most likely it will work. If they have different sizes,
Keith thompson
source share