Talk:Find common directory path: Difference between revisions
Content added Content deleted
No edit summary |
m (Rename the function to avoid the implication that it finds the shortest common path (which would be much simpler).) |
||
Line 6: | Line 6: | ||
#include <stdio.h> |
#include <stdio.h> |
||
static void |
static void longestSharedPath(const char *fixed, char *moving) { |
||
char *t; |
char *t; |
||
unsigned n = strspn(moving, fixed); |
unsigned n = strspn(moving, fixed); |
||
Line 27: | Line 27: | ||
strcpy(tmp, dir_list[0]); |
strcpy(tmp, dir_list[0]); |
||
while (dir_list[++i]) { |
while (dir_list[++i]) { |
||
longestSharedPath(dir_list[i], tmp); |
|||
} |
} |
||
printf("%s\n", tmp); |
printf("%s\n", tmp); |