Search code examples
c++csyntaxtimereadability

Time Function Syntax


Why is the time function usually used like this:

time_t currentTime;
currentTime = time( NULL );

instead of this:

time_t currentTime;
time( &currentTime );

Is the first method used more just because it is arguably more readable? Or is there another reason?

Thanks.

Edit: Also, why was the time function even designed this way? Why have two ways to set the variable?


Solution

  • It always seems to make more sense to return a value from a function than pass a paramter that is changed.

    This might be because we learned on languages where functions and subroutines were different, don't know about these youngsters today.