When we look at a cursor’s position with a text editor, we often see it displayed in lines and columns (e.g., line 7, column 62). We know that strings are represented in memory as a contiguous array of bytes. The question then becomes: how do we apply 2D concepts on top of a unidimensional array of bytes?

Get hands-on with 1400+ tech skills courses.