Given the standard definition for the main program:
int main(int argc, char *argv[]) {
...
}
Under which circumstances can argc
whenever you want to run any executable like ./a.out
it will have one argument thats the program name
. But It is possible to run a program with argc
as zero
in Linux, by executing it from another program that calls execv
with an empty argument list
.
for e.g
int main() {
char *buf[] = { NULL };
execv("./exe", buf); /* exe is binary which it run with 0 argument */
return 0;
}