0

Is it possible to use output from void function in an if statment in another function

void RightsCheck()
{
    // Check if I have admin rights && save it to fReturn
    // cout << fReturn;
}

void RunApp()
{
    if (fReturn == 1)
    {
        printf("Admin");
    }
    
    else if (fReturn == 0)
    {
        printf("User");
    }
}
  • A void function by definition doesn't return a value in c++. You can pass a parameter by reference and check its value after calling the function. [Why is there a need for reference parameters in C++?](https://softwareengineering.stackexchange.com/questions/312105/why-is-there-a-need-for-reference-parameters-in-c) – Jason Nov 15 '22 at 08:34
  • Or make the function return a value. [Demo](https://godbolt.org/z/nfoxGE7PG) – rturrado Nov 15 '22 at 08:44

0 Answers0