file-handling · intermediate · ~15 min
Track a line counter while scanning.
Implement int first_error_line(const char *log) returning the 1-based line number of the first line containing "ERROR", or -1 if there is none.
#include <string.h>
int first_error_line(const char *log) {
/* TODO */
return -1;
}
Solve this exercise in the browser editor — compile and run against the test harness, no setup required.