Zero as a placeholder was invented independently in civilizations around the world. The Babylonians got their number system from the Sumerians, the first people in the world to develop a counting system. Developed 4,000 to 5,000 years ago, the Sumerian system was positional — the value of a symbol depended on its position relative to other symbols. But Microsoft apparently decided to undefine zero. Instead of a single character zero is defined by Microsoft as "NULL". I don't know if it has a type nor do I care. Zero is zero is "0".

Success/Failure in "C"

Here is another truth in C and C++: Any non-zero integer value is considered to be true. When returning from a function a non-zero value will result in an if statement succeeding, i.e. the body of the if statement will be executed. A zero value is considered to be false and an if statement will fail.

Microsoft invented the "BOOL" type and it seems to be an integer (i.e. int). C defines a perfectly good type named "bool" which has a "true" and "false" value. Those two values seem fine for returning success/failure from a function. I try not to use a generic integer (i.e. BOOL) for return values where I specifically want to return success or failure.

However, there is one more situation that arises from time to time. When I wish to hide the details of a data structure with multiple records, all of which need processing in some way returning a pointer to a single record (think class or struc object) is useful. Consider the following code:

Record* rcd;
  for (rcd = table.startLoop(); rcd; rcd = table.nextRcd()) {
    int x = rcd->v;

The pointer rcd is supposed to point to a record in the table. The organization of table is such that the table function startLoop starts with the first item (however that is defined by the code in table, we do not know). The function startLoop returns a pointer or zero. So does the function nextRcd. So the body of the loop is guaranteed to contain a valid pointer every time. When all the records have been returned to the loop a zero is returned and the condition in the loop fails because it is zero. No need to test for zero, C and C++ both know that a value by itself is tested against zero every time! I try to not make the code harder to read with noise...

Did you notice that I placed the local variable declaration on the margin and the code two spaces indented? I try to put most of the declarations right after the function declaration in a function too.