PATH
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "fold.h"
#define PATH_SEPARATOR "/"
#define PATH_SEPARATOR_LENGTH (sizeof(PATH_SEPARATOR) - 1)
#define PATH(...) FOLD(path_impl, __VA_ARGS__)
char *path_impl(char *a, char *b) {
int al = strlen(a);
int bl = strlen(b);
char *r = malloc(al + PATH_SEPARATOR_LENGTH + bl + 1);
memmove(r, a, al);
memmove(r + al, PATH_SEPARATOR, PATH_SEPARATOR_LENGTH);
memmove(r + al + PATH_SEPARATOR_LENGTH, b, bl);
r[al + PATH_SEPARATOR_LENGTH + bl] = 0;
return r;
}
int main(void) {
char *t = PATH("eple", "hest", "tiar", "vara");
printf("%s\n", t);
return 0;
}INFO