I want to get the current executable’s file path without the executable name at the end.
I’m using:
char path[1024];
uint32_t size = sizeof(path);
if (_NSGetExecutablePath(path, &size) == 0)
printf("executable path is %s\n", path);
else
printf("buffer too small; need size %u\n", size);
It works, but this adds the executable name at the end.
dirname(path);should return path without executable after you acquire path with, that is on Unix systems, for windows you can do some strcpy/strcat magic.
For dirname you need to include
#include <libgen.h>…