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.)
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.)
On
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; }
On
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
It will return either
1or0depending upon the conditionret < 0istrueorfalse.You can understand this as