Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- Microsoft C 6.0 - <b>_searchenv() searches for a file using a path</b> http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
 _searchenv()            Searches for a file using a path

 #include   <stdlib.h>

  void _searchenv(name, env_var, path);
  char *name;       Name of file to search for
  char *env_var;    Environment variable containing path
  char *path;       Buffer to store path

    _searchenv() searches for the target file name using a list of
    directory paths that are specified by the environment variable
    env_var. env_var will most often be PATH, which searches for fname on
    all paths specified in the system PATH variable, but env_var can also
    be LIB, INCLUDE, or other user-defined environment variables.

    _searchenv() first searches the current working directory for the
    file. If it doesn't find the file there, it next searches the
    directories specified by the environment variable.

    If fname is found, the newly created path is copied to the buffer
    that path points to. You must ensure that path is large enough to
    hold the constructed path. If fname is not found path will contain an
    empty, null-terminated string.

   Portability:     MS-DOS only

 -------------------------------- Example ---------------------------------

 This program searches for cl.exe using the system PATH variable

           #include <stdlib.h>

           main()
           {
              char path[_MAX_PATH + 1];

              _searchenv( "cl.exe", "PATH", path);
              printf("Path: %s\n", path);
           }


See Also: _makepath() _splitpath()

Online resources provided by: http://www.X-Hacker.org --- NG 2 HTML conversion by Dave Pearson