In JavaScript you can call a function if a certain Boolean variable is true:
booleanVariable && functionToExecute();
Is it possible to do the same thing in C?
Thank you
CodePudding user response:
Yes, you can:
#include <stdio.h>
int functionToExecute()
{
printf("ran function");
return 1;
}
int main()
{
int booleanVariable = 1;
booleanVariable && functionToExecute();
return 0;
}
https://www.mycompiler.io/view/HIbRP3W1uil
CodePudding user response:
Try using if statement
if(booleanvaraible==true)
functionToExecute();