micro-utils/libmu/make_path.h
Your Name 6d1cf79ca6 fix
2023-10-31 12:53:32 +03:00

21 lines
435 B
C

#ifndef _MAKE_PATH_H
#define _MAKE_PATH_H
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
char *mu_make_path(const char *prog_name, const char *src, const char *dst) {
size_t len = strlen(src) + strlen(dst) + 2;
char *full_path = malloc(len + 1);
if (full_path == NULL) {
fprintf(stderr, "%s: malloc() fail\n", prog_name);
return NULL;
}
snprintf(full_path, len, "%s/%s", src, dst);
return full_path;
}
#endif