time function in C always displays “Wed Dec 31 23:59:59 1969”
问题 I require the current date and time to be logged for my application. I have written the code in C. I have attached the code #include <stdio.h> #include <time.h> int main() { time_t t; while(1) { time(&t); printf("Today's date and time : %s",ctime(&t)); } } The output is Today's date and time : Wed Dec 31 23:59:59 1969 Today's date and time : Wed Dec 31 23:59:59 1969 Today's date and time : Wed Dec 31 23:59:59 1969 Today's date and time : Wed Dec 31 23:59:59 1969 The time is not getting