To get current directory (where you execute your target program), you can use the following example code, which works for both Visual Studio and Linux/MacOS(gcc/clang), both C and C++:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#if defined(_MSC_VER)
#include <direct.h>
#define getcwd _getcwd
#elif defined(__GNUC__)
#include <unistd.h>
#endif
int main() {
char* buffer;
if( (buffer=getcwd(NULL, 0)) == NULL) {
perror("failed to get current directory\n");
} else {
printf("%s \nLength: %zu\n", buffer, strlen(buffer));
free(buffer);
}
return 0;
}