0

What does time(NULL) mean in the following :

srand48((long int)time(NULL)) ?

I see it being used in srand48 when we don't want a seed value.

1

According to this answer on Stackoverflow, the function time is normally passed a pointer to a time_t object (or struct) which it fills up with the current time. If you pass it null, however, you will just be handed the current time.

So srand48((long int)time(NULL)) can be translated to (in English):

Call srand48 with the current time reported by 'time' casted to a long integer

A long integer is then just an 8 bit integer.

Essentially you are just calling srand48 with the current time, the effect of which is a non-default seed value.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .