#include <stdio.h>
#include <time.h>
int main()
{
time_t seconds=time(NULL);
struct tm* current_time=localtime(&seconds);
printf("Current year = %d\n",(current_time->tm_year + 1900));
return 0;
}
time(NULL) function returns the time since 00:00:00 UTC, January 1, 1970 (Unix timestamp) in seconds.
tm_year indicates the number of the current year starting from 1900. So, to print the actual value of the current year, you will have to add 1900 to its value.
You need to import time.h header file to use these features.