networking · intermediate · ~15 min
Convert a hex chunk-size line to a number.
In HTTP chunked encoding each chunk starts with its size in hex. Implement long parse_chunk_size(const char *hex) returning the value of the hex string, or -1 if it has no hex digits.
#include <stdlib.h>
#include <ctype.h>
long parse_chunk_size(const char *hex) {
/* TODO */
return -1;
}
Solve this exercise in the browser editor — compile and run against the test harness, no setup required.