### _searchenv -- Search for File

Format

>     #include <stdlib.h>
>     void _searchenv(char *name, char *env_var, char *path);

Language Level: Extension
_searchenv searches for the target file in the specified domain. The env_var variable can be any environment variable that specifies a list of directory paths, such as PATH, LIB, INCLUDE, or other user-defined variables. Most often, it is PATH, causing a search for name in all directories specified in the PATH variable.

The routine first searches for the file in the current working directory. If it does not find the file, it next looks through the directories specified by the environment variable.

If the target file is found in one of the directories, the fully-qualified file name is copied into the buffer that path points to. You must ensure sufficient space for the constructed file name. If the target file is not found, path contains an empty null-terminated string.

Return Value
There is no return value.

Example
This example searches for the files _searche.c and icc.exe.

    #include <stdio.h>
    #include <stdlib.h>

    int main(void)
    {
       char path_buffer[_MAX_PATH];

       _searchenv("icc.exe", "PATH", path_buffer);
       printf("path: %s\n", path_buffer);
       _searchenv("_searche.c", "DPATH", path_buffer);
       printf("path: %s\n", path_buffer);
       return 0;

       /************************************************
          The output should be similar to:

          path: C:\ibmcpp\bin\icc.exe
          path: C:\src\_searche.c
       ************************************************/
    }

getenv -- Search for Environment Variables
putenv -- Modify Environment Variables
<stdlib.h>