if statement and a function

I have a function that will return an integer. I set the integer at the beginning to 0 and at the end, an if statement sets it to 1 if the function determines a problem.

How could I write a bit of code that will run this function if the function returns 0, and if the function does not return 0, move on to the else statement?

Is this correct?
1
2
3
4
5
6
7
8
if(exampleFunction(variable) == 0)
{
     cout << "run the if part" << endl;
}
else
{
     cout << "run the else part" << endl;
}
closed account (zb0S216C)
That seems to be fine.

Wazzak
Topic archived. No new replies allowed.