cybersecurity · intermediate · ~15 min · safe pentest lab
Generalise the find-label-then-number recipe.
Implement long proc_field(const char *status, const char *label) returning the integer after the label in a /proc/<pid>/status-style text, or -1 if absent. label includes its trailing colon, e.g. "PPid:".
#include <string.h>
#include <stdlib.h>
long proc_field(const char *status, const char *label) {
/* TODO */
return -1;
}
Solve this exercise in the browser editor — compile and run against the test harness, no setup required.