Created
May 16, 2017 13:50
-
-
Save njlr/c1604bfdca93674ddccccdf107a85866 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const int ERROR = 1; | |
const int SUCCESS = 0; | |
int compute(int input, int* output) { | |
if (cond(input)) { | |
return ERROR; | |
} else { | |
*output = computeOutput(input); | |
return SUCCESS; | |
} | |
} | |
// Usage | |
int output; | |
int input; | |
if (int error = compute(input, &output)) { | |
error_handler(error); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment