cybersecurity · intermediate · ~15 min · safe pentest lab
Parse a fixed-position field.
Implement int cve_year(const char *s) returning the 4-digit year from a valid CVE-YYYY-NNNN id, or -1 if s doesn't start with CVE- followed by 4 digits.
#include <string.h>
int cve_year(const char *s) {
/* TODO */
return -1;
}
Solve this exercise in the browser editor — compile and run against the test harness, no setup required.