networking · beginner · ~15 min
Detect the terminating zero-chunk.
Detect the terminating zero-sized chunk that ends a chunked HTTP body.
Implement int is_last_chunk(const char *hexsize).
hexsize: a chunk-size string in hexadecimal.Return 1 if the hex size parses to 0, else 0.
is_last_chunk("0") -> 1
is_last_chunk("000") -> 1 (still zero)
is_last_chunk("10") -> 0
"000") still represent the terminating chunk.hexsize: a chunk-size string in hexadecimal.
1 if the hex size parses to 0, else 0.
Parse base-16 and compare to 0.
#include <stdlib.h>
int is_last_chunk(const char *hexsize) {
/* TODO */
return 0;
}
Solve this exercise in the browser editor — compile and run against the test harness, no setup required.