Question 11
Back to Exercise
What is the output of the following C program?
#include <stdio.h>
#include <time.h>
int main(void) {
time_t t = 0;
char buf[40];
strftime(buf, sizeof buf, "%d %b %Y, %A", gmtime(&t));
puts(buf);
return 0;
}
- A 01 Jan 1970, Thursday Correct
- B 01 Jan 1900, Monday
- C 00 Jan 1970, Thursday
- D 01 Jan 1970, Sunday
Correct Answer: Option A
time_t 0 is the Unix epoch, midnight UTC on Thursday 1 January 1970. gmtime avoids any dependence on the local time zone.
Discussion & Comments 0
Share your method, a shortcut, or ask about a step you didn't follow.
No comments yet. Be the first to share your solution!