rendered paste bodychar *getPath(char *path, const char *progName) { char *pathTok; char tmp; DIR *dirp; struct dirent *dp; pathTok = strtok(path, ":"); int found = 0; while(pathTok != NULL) { if ((dirp = opendir(pathTok)) == NULL) { printf("Could not open %s", pathTok); return NULL; } do { if ((dp = readdir(dirp)) != NULL) { if (strcmp(dp->d_name, progName) == 0) { pathTok = strcat(pathTok, "/"); pathTok = strcat(pathTok, dp->d_name); char *returnPath = malloc(sizeof(tmp) * MAXBUF); memset(returnPath, 0, sizeof(tmp) * MAXBUF); strncpy(returnPath, pathTok, sizeof(pathTok)); return returnPath; } } } while (dp != NULL); pathTok = strtok(NULL, ":"); } return NULL;}