Solution for Exercise 21-3
ex2103
#include <stdio.h>
#include <time.h>
int main()
{
time_t tictoc;
time(&tictoc);
printf("The time is now %s",ctime(&tictoc));
return(0);
}
Output
The time is now Mon May 18 13:54:31 2020
Notes
* As with the time() function, you must pass the address of the time_t variable to the ctime() function, shown at Line 9 above.
* The string returned by ctime() is terminated with a newline (followed by the null character, natch), which is why the newline character isn't included in the printf() format string.
Copyright © 1997-2025 by QPBC.
All rights reserved
