Is there a C function call in linux that helps me get all the files in the directories of $PATH as a list or an array? Or should we parse through the $PATH variable manua开发者_如何学Clly to get them?
#include <stdlib.h>
char *colon_delimited_path = getenv("PATH")
returns a :
-delimited list of the directories in PATH. To translate to an array, you can use strtok
to split the string.
精彩评论