| ▲ | kevin_thibedeau 13 hours ago | |||||||||||||
There are (rare) times when you want negative array indices. C lets you index in both directions from a pointer to the middle of an array. That's why array indexing is signed in C. Some libc ctypes lookup tables do this. For sizing there is no strong case for negatives other than to shoehorn them into signed operations. | ||||||||||||||
| ▲ | throwaway894345 13 hours ago | parent [-] | |||||||||||||
That’s interesting but seems pretty dangerous. How do you know you aren’t going to decrement off the front of the array? Keeping the pointer to the first element in the array and using offsets seems safer for humans and I don’t think the computer would care. | ||||||||||||||
| ||||||||||||||