I’m trying to read an ” Makefile ” in C/C++
it works by doing: system("make -C /Users/MyNAME/Desktop/Folder flash");
” make flash ” is the command to run the file and /Users/MyNAME/Desktop/Folder is the
file path. This code works, but how can i make the file path locally, to read from the same
debug folder ( where the program is ) without writing it manually ?
You probably want the
int chdir(const char *path);function. Example:There’s a lot of other useful functions in
<unistd.h>, which should be present on any POSIX-based system. Check here for the big list.EDIT: If the path isn’t constant, you’ll probably want to provide it as a command line argument to your program:
Run it with a line like
./foo /Users/MyNAME/Desktop/Folder.