The buffer is a string of memory organized as you wrote: row 0 = 0 to NCOLS - 1, row 1 = NCOLS to NCOLS * 2 - 1. As for the code: it would work, but it should only copy NROWS - 1. The buffer elements
are being shifted -1 row: i is initially 0, and videoMemory[i] is getting the value of the next row (i + NCOLS). So let's say you had a 5 column video display (NCOLS = 5), this is what's going on:
Code:
line 0 (address 0 to NCOLS - 1) : *****
line 1 (address NCOLS to NCOLS * 2 - 1): 12345
videoMemory[0] = videoMemory[NCOLS + 0], line 0: 1****
videoMemory[1] = videoMemory[NCOLS + 1], line 0: 12***
videoMemory[2] = videoMemory[NCOLS + 2], line 0: 123**
videoMemory[3] = videoMemory[NCOLS + 3], line 0: 1234*
videoMemory[4] = videoMemory[NCOLS + 4], line 0: 12345