that feel when your CS lecturer starts loops from 1 instead of 0.
Name:
Anonymous2012-10-16 21:54
Some languages have a function that returns the first index of a substring in a larger string. With one-based arrays, it returns N if it begins at the Nth character, or 0 if the substring can't be found. With zero-based arrays, it returns N-1 for the Nth character (such as 0 for the 1st character), otherwise it's usually either -1 or one more than the length of the string. Using signed numbers cuts the maximum string length in half. Consider using these results as booleans. What's more natural?
Think about C's null pointer. This is an address with a value of 0, used in the exact same way 0 is used with one-based arrays in the previous example. You can't dereference this null pointer even though it's a possible pointer value, just like you can't index a one-based array with 0 even though it's an unsigned integer.