Off-by-one errors - Recommendations.
If
you have a 512 byte buffer you can only store 511 characters in the string (the last character is a NULL).
If
you use scanf() to read into a buffer you also have to account for the NULL: use scanf(%511s, &My512ByteBuffer) instead of scanf(%512s,
&My512ByteBuffer) which is unsafe.
If
you declare an array as int A[100], remember that you cant
access A[100], the highest index you can access is A[99] and the
lowest is A[0].
The
best defense against off-by-one errors of any kind is a thorough combination of testing and code inspection.