int valorNo = (p->left == NULL && p->right == NULL) ? p->key : 0;
I saw this in an answer here in the stack and I have no idea how this works, much less how to "read" it.
int valorNo = (p->left == NULL && p->right == NULL) ? p->key : 0;
I saw this in an answer here in the stack and I have no idea how this works, much less how to "read" it.
This is a Ternary Operator. Basically, it's the same thing to do:
if (p->left == NULL && p->right == NULL)
{
int valorNo = p->key;
}
else
{
int valorNo = 0;
}
Being structured as follows:
(CONDIÇÃO) ? OPERAÇÃO VERDADEIRA : OPERAÇÃO FALSA;
This is a simplified way to create conditions in the code.