best practice when referring to a program's name in C
Posted
by guest
on Stack Overflow
See other posts from Stack Overflow
or by guest
Published on 2010-06-11T17:35:17Z
Indexed on
2010/06/11
17:42 UTC
Read the original article
Hit count: 212
what is considered best practice when referring to a program's name? i've seen
#define PROGRAM_NAME "myprog"
printf("this is %s\n", PROGRAM_NAME);
as well as
printf("this is %s\n", argv[0]);
i know, that the second approach will give me ./myprog
rather than myprog
when the program is not called from $PATH
and that the first approach will guarantee consistence regarding the program's name.
but is there anything else, that makes one approach superior to the other?
© Stack Overflow or respective owner