I have been trying to print the linked list the program below creates, to see how the path information is actually organized inside of it, having no success in the process.

Code:
[COLOR=var(--highlight-keyword)]#[/COLOR][COLOR=var(--highlight-keyword)]define[/COLOR][COLOR=var(--highlight-keyword)] TRUE 1[/COLOR]
[COLOR=var(--highlight-keyword)]#[COLOR=var(--highlight-keyword)]define[/COLOR] FALSE 0[/COLOR]

[COLOR=var(--highlight-keyword)]extern[/COLOR] [COLOR=var(--highlight-namespace)]char[/COLOR] **environ;
 
[COLOR=var(--highlight-comment)]/*
 * struct Node - singly linked list
 * @str: string - (malloc'ed string)
 * @next: points to the next node
 * Description: singly linked list node structure
 */[/COLOR]
[COLOR=var(--highlight-keyword)]typedef[/COLOR] [COLOR=var(--highlight-keyword)]struct[/COLOR] [COLOR=var(--highlight-literal)]Node[/COLOR]
{
 [COLOR=var(--highlight-namespace)]char[/COLOR] *str;
 [COLOR=var(--highlight-keyword)]struct[/COLOR] [COLOR=var(--highlight-literal)]Node[/COLOR] *[COLOR=var(--highlight-literal)]next[/COLOR];
}

 [COLOR=var(--highlight-comment)]/**
 * _getenv - searches for the environment string
 * pointed to by name 
 * @name:  This is the C string containing the name
 * of the requested variable
 * Return: the associated value to the string.
 */[/COLOR]
[COLOR=var(--highlight-namespace)]char[/COLOR] *_getenv([COLOR=var(--highlight-keyword)]const[/COLOR] [COLOR=var(--highlight-namespace)]char[/COLOR] *name)
{
    [COLOR=var(--highlight-namespace)]int[/COLOR] i, j; [COLOR=var(--highlight-comment)]/* Counters */[/COLOR]
    [COLOR=var(--highlight-namespace)]int[/COLOR] status; [COLOR=var(--highlight-comment)]/* boolean variable */[/COLOR]


    [COLOR=var(--highlight-keyword)]for[/COLOR] (i = [COLOR=var(--highlight-namespace)]0[/COLOR]; environ[i] != [COLOR=var(--highlight-literal)]NULL[/COLOR]; i++) [COLOR=var(--highlight-comment)]/* loop over the array of pointers to strings called "environment" until it finds a string value called NULL (the last one) */[/COLOR]
    {
        status = [COLOR=var(--highlight-namespace)]1[/COLOR]; [COLOR=var(--highlight-comment)]/* initialize the status variable as TRUE (1) */[/COLOR]
        [COLOR=var(--highlight-keyword)]for[/COLOR] (j = [COLOR=var(--highlight-namespace)]0[/COLOR]; environ[i][j] != [COLOR=var(--highlight-variable)]'='[/COLOR]; j++)  [COLOR=var(--highlight-comment)]/* loop over the the current string value until the symbol '=' is found */[/COLOR]
        {
            [COLOR=var(--highlight-keyword)]if[/COLOR] (name[j] != environ[i][j]) [COLOR=var(--highlight-comment)]/* Check if each byte of the current string value is exactly the same as name */[/COLOR]
            {
                status = [COLOR=var(--highlight-namespace)]0[/COLOR]; [COLOR=var(--highlight-comment)]/* if they are not, we notify (set the status variable as FALSE (0)) and break */[/COLOR]
                [COLOR=var(--highlight-keyword)]break[/COLOR];
            }
        }

        [COLOR=var(--highlight-keyword)]if[/COLOR] (status) [COLOR=var(--highlight-comment)]/* IF and ONLY IF we have found that each byte of the current string value is exactly the same as name  */[/COLOR]
        {
            [COLOR=var(--highlight-keyword)]return[/COLOR] (&environ[i][j + [COLOR=var(--highlight-namespace)]1[/COLOR]]); [COLOR=var(--highlight-comment)]/* return the address of the current string value excluding the "=" sign */[/COLOR]
        }
    }
    [COLOR=var(--highlight-keyword)]return[/COLOR] ([COLOR=var(--highlight-literal)]NULL[/COLOR]); [COLOR=var(--highlight-comment)]/* This function returns NULL if the environment variable requested does not exist */[/COLOR]
}              [COLOR=var(--highlight-comment)]/* if the previous return was successfully executed, this return is not executed */[/COLOR]

[COLOR=var(--highlight-comment)]/**
 * _getpathdir - creates a linked list for
 * any environment string
 * @path: the selected environment string
 * @pathCopy: a duplicate of @path
 * Return: a linked list of @path
 */[/COLOR]
Node *_getpathdir([COLOR=var(--highlight-namespace)]char[/COLOR] *path, [COLOR=var(--highlight-namespace)]char[/COLOR] **pathCopy)
{
    [COLOR=var(--highlight-namespace)]char[/COLOR] *token = [COLOR=var(--highlight-literal)]NULL[/COLOR];
    Node *head;
    Node *pathNode;


    [COLOR=var(--highlight-keyword)]if[/COLOR] (path == [COLOR=var(--highlight-literal)]NULL[/COLOR]) [COLOR=var(--highlight-comment)]/* If path passed is NULL, return NULL */[/COLOR]
        [COLOR=var(--highlight-keyword)]return[/COLOR] ([COLOR=var(--highlight-literal)]NULL[/COLOR]);

    *pathCopy = strdup(path); [COLOR=var(--highlight-comment)]/* Make a duplicate of path parameter */[/COLOR]

    head = [COLOR=var(--highlight-literal)]NULL[/COLOR]; [COLOR=var(--highlight-comment)]/* Initialize the very first token of the linked list to NULL */[/COLOR]
    pathNode = [COLOR=var(--highlight-literal)]malloc[/COLOR]([COLOR=var(--highlight-keyword)]sizeof[/COLOR](Node)); [COLOR=var(--highlight-comment)]/* This allocates pathNode for its use in the very first head */[/COLOR]
    [COLOR=var(--highlight-keyword)]if[/COLOR] (pathNode == [COLOR=var(--highlight-literal)]NULL[/COLOR]) [COLOR=var(--highlight-comment)]/* If there's not enough memory to allocate pathNode, return NULL */[/COLOR]
        [COLOR=var(--highlight-keyword)]return[/COLOR] ([COLOR=var(--highlight-literal)]NULL[/COLOR]);

    token = strtok(*pathCopy,  [COLOR=var(--highlight-variable)]":"[/COLOR]); [COLOR=var(--highlight-comment)]/* Break the pathCopy string into tokens, separator used is ':' */[/COLOR]
    pathNode->str = token; [COLOR=var(--highlight-comment)]/* The first element to add to the linked list is token */[/COLOR]
    pathNode->next = head; [COLOR=var(--highlight-comment)]/* The "next" element to add to the linked list will be the new head */[/COLOR]
    head = pathNode;  [COLOR=var(--highlight-comment)]/* Assign pathNode to the head */[/COLOR]
    [COLOR=var(--highlight-keyword)]while[/COLOR] (token != [COLOR=var(--highlight-literal)]NULL[/COLOR]) [COLOR=var(--highlight-comment)]/* Fill the linked list with the rest of the string */[/COLOR]
    {
        token = strtok([COLOR=var(--highlight-literal)]NULL[/COLOR], [COLOR=var(--highlight-variable)]":"[/COLOR]); [COLOR=var(--highlight-comment)]/* By passing NULL as the first parameter to strtok(), we make sure that strtok() keeps working with */[/COLOR]
                                   [COLOR=var(--highlight-comment)]/* the previous parameter (pathCopy) */[/COLOR]
        [COLOR=var(--highlight-keyword)]if[/COLOR] (token == [COLOR=var(--highlight-literal)]NULL[/COLOR]) [COLOR=var(--highlight-comment)]/* Don't save token NULL in list */[/COLOR]
            [COLOR=var(--highlight-keyword)]break[/COLOR];
        pathNode = [COLOR=var(--highlight-literal)]malloc[/COLOR]([COLOR=var(--highlight-keyword)]sizeof[/COLOR](Node)); [COLOR=var(--highlight-comment)]/* This allocates pathNode for its use in the rest of the heads */[/COLOR]
        [COLOR=var(--highlight-keyword)]if[/COLOR] (pathNode == [COLOR=var(--highlight-literal)]NULL[/COLOR]) [COLOR=var(--highlight-comment)]/* If there are no more tokens left to add to the linked list, return NULL */[/COLOR]
            [COLOR=var(--highlight-keyword)]return[/COLOR] ([COLOR=var(--highlight-literal)]NULL[/COLOR]);
        pathNode->str = token; [COLOR=var(--highlight-comment)]/* Add to the linked list the current token */[/COLOR]
        pathNode->next = head; [COLOR=var(--highlight-comment)]/* The "next" element to add to the linked list will be the new head */[/COLOR]
        head = pathNode; [COLOR=var(--highlight-comment)]/* Assign pathNode to the head */[/COLOR]
    }
    [COLOR=var(--highlight-keyword)]return[/COLOR] (head);

}


[COLOR=var(--highlight-comment)]/**
 * listpath - Calls the functions _getenv and _getpathdir
 * @pathCopy: A variable that will store a duplication
 * of the "PATH" parameter
 * Return: A linked list of PATH directories
 */[/COLOR]
Node *[COLOR=var(--highlight-literal)]listpath[/COLOR]([COLOR=var(--highlight-namespace)]char[/COLOR] **pathCopy)
{
    [COLOR=var(--highlight-namespace)]char[/COLOR] *getEnv;
    Node *pathDirs;

    getEnv = _getenv([COLOR=var(--highlight-variable)]"PATH"[/COLOR]);
    pathDirs = _getpathdir(getEnv, pathCopy); [COLOR=var(--highlight-comment)]/* Here pathCopy is passed as the address of itself pointing to NULL, i.e. `char *pathCopy = NULL` */[/COLOR]

    [COLOR=var(--highlight-keyword)]return[/COLOR] (pathDirs); [COLOR=var(--highlight-color)]}[/COLOR]


I tried to use the following loop to print to the sdtout, it compiles, but doesn't print anything actually , so, I would like to know what I'm doing wrong here, or if there's another way in which _getpathdir function could print its linked list to the stdout before returning head

Code:
[COLOR=var(--highlight-namespace)]int[/COLOR] [COLOR=var(--highlight-literal)]main[/COLOR]()
{
  Node *head = [COLOR=var(--highlight-literal)]NULL[/COLOR];
  Node *current_node = head;
  [COLOR=var(--highlight-namespace)]char[/COLOR] *pathCopy = [COLOR=var(--highlight-literal)]NULL[/COLOR];
  listpath(&pathCopy);
  [COLOR=var(--highlight-keyword)]while[/COLOR] ( current_node != [COLOR=var(--highlight-literal)]NULL[/COLOR])
  {
    [COLOR=var(--highlight-literal)]printf[/COLOR]([COLOR=var(--highlight-variable)]"\n %s\n"[/COLOR], current_node->str);
    current_node = current_node->next;
  }
  [COLOR=var(--highlight-keyword)]return[/COLOR] ([COLOR=var(--highlight-namespace)]0[/COLOR]);
}