114k views
5 votes
When subscripts are used to specify character positions in a string, the last character subscript is the same as the string's length?

User Giraffesyo
by
8.0k points

1 Answer

4 votes
Not true. If I would store the text "ABC" the subscripts would be:

buffer[0] == 'A'
buffer[1] == 'B'
buffer[2] == 'C'

As you can see, subscript 2 points to the last character, yet the length is 3.
User Ivan Gritsenko
by
8.3k points