function?
nope, command
there are two types of terminal commands, builtin which are programmed inside of the shell program and external which are executables. for the first one just exec the shell and veriffy the returned value for the second one you just could check if the file exist or not but the first way also works.
how do I know the location of the executable?
path env variable is one way
seems like the best way, is there some libc helper for that?
getenv, you also could pass it to main, there are many ways to check the path env var, for example in windows you could check a registry key, etc
Обсуждают сегодня