I know in C the last character was the null character, but I'm confused what this means?
so why do we subtract it by one?Code:if ( sz[ strlen( sz ) - 1 ] == '\\' ) // Is last character a '\'?
// . . .
I know in C the last character was the null character, but I'm confused what this means?
so why do we subtract it by one?Code:if ( sz[ strlen( sz ) - 1 ] == '\\' ) // Is last character a '\'?
// . . .
Arrays start at zero. If strlen is 8, and you want to access the eighth letter, what number should you put in the brackets?
Think about the smallest case possible.
A string one character long, just an X say. It will have sz[0] = 'X' and sz[1] = '\0' (null terminator).
Clearly the string length here is 1, but clearly you don't want to get sz[1].