Quote Originally Posted by Yonut View Post
Sorry, I just noticed this. The reason why I use `basename` on the program name (or argv[0]) is because argv[0] depends on where and how the program is called.

Code:
ie:
$ run_my_program (in $PATH)    -    argv[0] = "run_my_program"
$ ./run_my_program             -    argv[0] = "./run_my_program"
$ /home/user/run_my_program    -    argv[0] = "/home/user/run_my_program"
I don't care where the program resides, when error reporting. So I strip it first thing. It's just cleaner to my eyes. And like I said, this is all in a template, I never have to type anything other than my desire to use `program_name` when I need to.
FWIW, unless you intend to modify it at some point, the `program_name` buffer isn't even necessary. The pointer returned by `basename` can be stored in a variable. No allocation needed.