(Update below)
At the time of writing this, the Mozilla Coding Style guidelines have this recommendation under “General C/C++ Practices”:
Don’t put an else right after a return. Delete the else, it’s unnecessary and increases indentation level.
I can appreciate this in some circumstances, such as when checking for an error case early in a long function:
void f()
{
[...]
Everyone knows that global variables are bad and should be avoided wherever possible. Why? Because each global variable is, in effect, an implicit argument to every function that can see the global variable. The same thing is true of any non-local state.
And the presence of non-local state means that you can’t reason locally about your [...]
Posted in C, Correctness, Valgrind on March 13th, 2009 1 Comment »
Here’s what sounds like a simple question: in C, what’s the best way to convert a string representing an integer to an integer?
The good way
One way is to use the standard library function called strtol(). There are a number of similar functions, such as strtoll() (convert to a long long) and strtod (convert to a [...]