Checkpoint: Hardened Field Parser
Challenge on lesson: Checkpoint: Hardened Field Parser
CHALLENGE
Difficulty: advanced+25 XP
ISO C. A record is name:score (name up to 15 chars, score a decimal integer). Implement int parse_record(const char *line, char *name, size_t namesz, int *score) โ split on the FIRST ':'; copy the name into name only if it fits (NUL included), parse the score with the strictness of strtol (digits only between optional leading +/-; empty or trailing garbage refuses). Return 0 on success; -1 on any refusal (NULL args, no colon, name too long, bad score). Refused outputs are untouched.
Press Submit to check your solution.
Back to lesson: Checkpoint: Hardened Field Parser