user1797147 user1797147 - 1 year ago 58
C Question

What is the meaning of expression a = b != c;

I have the following code that I don't understand

shiftLeft = local.tasks.first != NULL;
local.tasks.last = NULL;

I mean the shiftLeft variable (which is boolean) supposed to be evaluated last, so in the first place evaluates local.tasks.first != NULL, but what is that?

Answer Source

This will return either true or false value (depending on fact if local.task.first is a NULL value or not).

If local.task.first is NULL a shiftLeft variable will get false value,

If local.task.first is not a NULL value a shiftLeft variable will get true value.

What is important, we don't know type of shiftLeft, if it is a bool variable it will be "filled" with true or false value. If it is other kind of variable (for example an integer) it will be "filled" with 0 for false and with something different than 0 for true (but we can't be sure what exactly).

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download