Home > Software design >  What is the explanation of the first line of the function secret?
What is the explanation of the first line of the function secret?

Time:02-05

What is the meaning of the first line in the function secret? What is the output of return secret(3,argv)?

#include <stdio.h>
int secret(int argc, char **argv)
{
 *argv && secret(0, argv   1) &&
 argc == 0 && printf("%s\n", *argv);
 return argc == 0;
}
int main()
{
 char *argv[] = {"hello", "XYZ", "123", "ABC", NULL};

 return (secret(3,argv));
}

CodePudding user response:

This

*argv && secret(0, argv   1) &&
argc == 0 && printf("%s\n", *argv);

is a tricky (and harder to read, I think) way to write

if ( *argv && secret(0, argv   1) && argc == 0 ) {
    printf("%s\n", *argv);
}
  •  Tags:  
  • Related