Created
December 22, 2008 16:09
-
-
Save nopcoder/39031 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
path = getenv("PATH"); | |
if (path != NULL) { | |
path = strdup(path); | |
for (dir = strtok(path, ":"); dir != NULL; dir = strtok(NULL, ":")) { | |
strcpy(candidate, dir); | |
strcat(candidate, "/"); | |
strcat(candidate, argv[0]); | |
if (access(candidate, X_OK) == 0) { | |
printf("executable is '%s' (from PATH).\n", candidate); | |
return 0; | |
} | |
} | |
free(path); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment