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

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


#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.