the common method is to do the positive / -1 for functions that return valid values for normal use since you can easily pluck out -1. For most other functions (mainly predicate functions) the return values are 1 for a positive result and 0 for a negative one, for use in:
Code: Select all
if (allisok()) {
// do something
} else {
// complain
}
The if statement is implicitly true for all nonzero and false for zero. You can also use this with pointers, just an fyi:
Code: Select all
char *something = argv[2];
if (something) // something is not null
For returning values for most others, I use more elaborate return types, commonly a char *, int, double or something like that, and for the most exquisite functions I could use a pair<T1, T2> or a struct tailor-made for it. I also occasionally use haskell/prolog style argument passing, in which all functions are void in return type and can modify their arguments. I do this mainly for clarity in programs that process stuff like images sequentially, since you're not constantly reassigning the pointer to the newer stuff.