I have created a shell file which is executing another C files, if all the files are in the same directory then there is no problem but if my shell file is happened to be in a different directory than my C files, how would I get that shell file to run a C program present in a different directory?
1 Answer
It is irrelevant for your question, where an executable is located (and in particular whether or not it is located in your working directory), and whether or not it has been compiled from C or something else. In general, if you want to execute a program X, you have three possibilities:
(1) Absolute path:
/my/path/to/X
(2) Relative path:
my/path/to/X
(this is equivalent to "$PWD/my/path/to/X")
(3) No path:
X
In the last case, the directories in the variable PATH are searched, until one is found which contains an executable named X.
/other/directory/C-program.