Question

Functions can return a number, pointer, and most of the type you want, but what's the meaning of it?

return ret < 0;

(This code snippet is from the last line of the code, ffprobe.c.)

Was it helpful?

Solution

It will return either 1 or 0 depending upon the condition ret < 0 is true or false.

You can understand this as

if(ret < 0)
    return 1;
else  
    return 0;

OTHER TIPS

It returns the value of the conditional operation. ret < 0 It's C shorthand that you often see. C programmers are notoriously pedantic and do not write code that is obvious to the learner. It's equivalent to what might be written explicitly for mortals as

if ( ret < 0 ) { return true; } else { return false; }

return statement can have a expression. when a function is returning using a return statement it evaluates the expression first.

       return (expression);

expression can be any valid expression in C. after evaluation it returns whatever value is the output of the expression(assuming the return type matches or compiler will through an error ) in your case the statement will be like

      return (ret < 0);

depending on the value of ret either 1( if ret is less than 0) or 0(if ret is greater than 0) will be returned

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top