c语言身份证号码看是否成年了

c语言编写程序,输入身份证号码看是否成年了。
已知某人身份证号码的指针char *idno,编写函数,判断该人是否超过十八岁,如果是,返回1,否则返回0.
int judge(char *idno)


#include <time.h>

int is_adult(const char *idno) {
    // 将身份证号码的前 6 位转换为出生年份
    int year = (idno[6] - '0') * 1000 + (idno[7] - '0') * 100 + (idno[8] - '0') * 10 + (idno[9] - '0');
    // 获取当前年份
    time_t current_time = time(NULL);
    struct tm *tm = localtime(&current_time);
    int current_year = tm->tm_year + 1900;
    // 如果当前年份减去出生年份大于 18,则表示该人已经成年
    return current_year - year > 18;
}