networking · intermediate · ~15 min
Extract the status code from a response.
Implement int parse_status_code(const char *resp) returning the numeric status from a response status line like HTTP/1.1 200 OK, or -1 if it doesn't start with HTTP/.
#include <string.h>
#include <stdlib.h>
int parse_status_code(const char *resp) {
/* TODO */
return -1;
}
Solve this exercise in the browser editor — compile and run against the test harness, no setup required.