Do you have any useful rules of thumb you follow when writing a function to use output parameters rather than a direct "return value?"
For example, say we have a function like this:
Code:void util_get_string_int(const char *input, int *output) { assert(input && output); if(!str_contains_all_digits(input)) { *output = -1; return; } *output = atoi(input); return; }
This version returns the int in an output parameter. Instead, I could just return these int values as actual ints in the return value but for this purpose, I figured I would already have an int stored in memory, so might as well just use that one.
What types of things do you consider before you make these decisions?