4 ms·
That has merit. Personally I usually find myself doing something more like this: if (argc != 3) { printf ("Wrong number of arguments"); // throw
by qntm 15y ago
That has merit. Personally I usually find myself doing something more like this:
if (argc != 3) {
printf ("Wrong number of arguments");
// throw an exception or return NULL or something
}
if (!fname) {
printf ("File name cannot be null");
// throw an exception or return NULL or something
}
/* Do stuff */
The important thing, to my mind, is the absence of an else block.
- VBprogrammer 15y agoYeah, that is a pattern I occasionally use but I prefer what I have written above as the control flow is more explicit. A missing return (or even one which is quite deliberately omitted) is much harder to spot.