50 ms·
Using nonzero for errors means you can do the same thing. This is common in things like this: if(somefunc()) goto fail; Additionally, if the return is a f
by userbinator 13y ago
Using nonzero for errors means you can do the same thing. This is common in things like this:
if(somefunc()) goto fail;
Additionally, if the return is a fail/pass status, there is only one success (0), and you can use all the nonzero values for error codes.
- prewett 13y agoYes, you can, but that doesn't read very well to my eyes, given most function names. if(open()), if(read()), if (CreateWindowExW()), all suggest success to me. if (!open(...)) goto fail; if (!read(...)) goto fail; if (!close(...)) goto fail; reads a lot nicer to me. Although, the reality is that you need to assign to an error variable, which makes it not as nice and clean.