RicardasSim

if statement with initializer

Jun 1st, 2024 (edited)
1,049
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.30 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <stdbool.h>
  4.  
  5. bool TestFnc()
  6. {
  7.     printf("TestFnc\n");
  8.     return true;
  9. }
  10.  
  11. int main()
  12. {
  13.  
  14.     bool a = false;
  15.  
  16.     if( a = TestFnc(); a )
  17.     {
  18.         printf("1\n");
  19.     }
  20.     else
  21.     {
  22.         printf("2\n");
  23.     }
  24.  
  25.     return 0;
  26. }
  27.  
Advertisement