Finding text inside a log path

A log viewer runs the following searches. Assume string.h has been included and all statements execute successfully.


C
const char path[] = "/srv/log/archive/log.txt";
const char *a = strchr(path, '/');
const char *b = strrchr(path, '/');
const char *c = strstr(path, "log");
const char *d = strstr(path + 9, "log");
const char *e = strchr(path, 'z');


For each returned pointer, enter its byte offset, meaning its zero-based distance in bytes from the beginning of path. Use exact integers. Enter absent when the function returns a null pointer. Measure every offset from path, including the search that starts at path + 9.

PointerOffset from path or absent
a
b
c
d
e

Create a free account to get started

Unlock full course notes by signing up

  • Video lessons taught by top educators
  • Practice questions with guided solutions
  • Written review notes for reference
  • Expert answers anytime from course tutors

More Strings and string.h Questions: