I\'m having trouble return a string from a function. It prints out a garbage value in the main method. I saw a similar question on this forum but the results on that page didn\'
You are assigning values path_name more than it can actually hold.
path_name
strncat(path_name, dir[i], sizeof(path_name)); strncat(path_name, "/", sizeof(path_name)); strncat(path_name, argv[0], sizeof(path_name));
should be:
sprintf(path_name, "%s%s%s", dir[i],"/",argv[0]);