Lets say I have a function:
void split_path_file(char** p, char** f, char *pf) { //malloc and set *p to file path, malloc and set *f to file name //p
void split_path_file(char** p, char** f, char *pf) { char *slash = pf, *next; while ((next = strpbrk(slash + 1, "\\/"))) slash = next; if (pf != slash) slash++; *p = strndup(pf, slash - pf); *f = strdup(slash); }
(If pf == slash, then there is no directory component.)
pf == slash