November 2018
Beginner
304 pages
7h 35m
English
Iteration is used frequently with files; iteration can be used to read the information in the file and process it in an orderly manner. It also limits the amount of memory taken up when a file is read, which not only reduces system resource use but can also improve performance. The following screenshot demonstrates this:

Basically, the code in line 80 opens a temporary file in memory and reads each line from afile.txt, printing each one to the screen, until the end-of-file marker is reached. Unlike previous examples, using a for loop won't print the EOF marker because, once that marker is reached, ...
Read now
Unlock full access