开发者

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

开发者 https://www.devze.com 2023-04-12 02:58 出处:网络
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?

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

精彩评论

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