What's the best way to handle relative paths passes as parameters to a program, accessed with argc/argv?
For example, I've got a script program named "bob" that takes a parameter for a file with a picture:
What's the best way to access mypic.jpg?
Also, I realize that when the script is executed as a relative or full path (i.e. "./bob" or "/Users/me/bob") I can just read argv[0] for the script's name, but what if it's located in /usr/bin and it's run just by "bob" - how is the path of program found then?
For example, I've got a script program named "bob" that takes a parameter for a file with a picture:
Code:
./bob mypic.jpg
Also, I realize that when the script is executed as a relative or full path (i.e. "./bob" or "/Users/me/bob") I can just read argv[0] for the script's name, but what if it's located in /usr/bin and it's run just by "bob" - how is the path of program found then?