Is there any way to declare variable in if statement (using ANSI C only) ?
Example:
if(int variable = some_function())
{
return 1;
}
Is there any way to declare variable in if statement (using ANSI C only) ?
Example:
if(int variable = some_function())
{
return 1;
}
No, you cannot do that.
What you can do is create a block just for the
if
Note that for this simple case you can call the function as the condition of the
if
(no need for an extra variable)