Quote:Original post by Eeyore
Hey all, I just wanted some help understanding some code.const char *cmd = argv[0] && *argv[0] ? argv[0] : "git-help";
This is logically equivalent to:
const char *cmd;if (argv[0] != NULL){ if (*argv[0] != NULL) { cmd = argv[0]; } else { cmd = "git-help"; }}else{ cmd = "git-help";}
That is because of the early-out of the && operator. If the left condition fails, it will never check/execute what's on the right side.