开发者

How to get directories in $PATH as a list or array?

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜