Multiple choice

time_t t; Which of the following statements will properly initialize the variable t with the current time from the sample above?

  1. t = clock();

  2. time( &t )

  3. t = ctime();

  4. t = localtime();

  5. None of the above

Reveal answer Fill a bubble to check yourself
B Correct answer
Explanation

The time() function takes a pointer to a time_t variable and sets it to the current calendar time, returning the same value.