#include <time.h> char buf[100]; struct tm here; const time_t now = time(NULL); localtime_r(&now, &here); strftime(buf, size(buf), "%Y", &here); // You almost certainly don't want %G.Or
snprintf(buf, sizeof(buf), "%d", here->tm_year + 1900); // Don't forget to add 1900Hacker News discusssion. https://news.ycombinator.com/item?id=17066739