Skip to main content

CSV Line Validator & Parser

Challenge on lesson: Checkpoint: Parsing Untrusted Input

Implement a one-line CSV parser for the format name,age,score (name: 1..15 non-comma chars; age: 0..130; score: 0..100). The boilerplate declares: ``c /* parses exactly three fields. Returns 0 and fills outputs on success. Returns -1 on ANY deviation: wrong field count, empty name, name too long, non-numeric or out-of-range age/score, trailing junk. line is NOT modified. */ int csv_parse(const char *line, char name[16], int *age, int *score); ``

Difficulty: intermediate

Back to lesson: Checkpoint: Parsing Untrusted Input