To properly initialize the variable t
with the current time, you can use the time()
function from the ctime
library.
Option A) t = ctime();
- This option is incorrect because the ctime()
function returns a string representation of the current time, not the actual time value.
Option B) time( &t );
- This option is correct because it calls the time()
function and passes the address of t
as an argument, allowing time()
to store the current time value in t
.
Option C) t = localtime();
- This option is incorrect because the localtime()
function converts a time value into a broken-down time structure, not the current time.
Option D) t = clock();
- This option is incorrect because the clock()
function measures the processor time, not the current time.
The correct answer is Option B.