diff --git a/main.cpp b/main.cpp index b9d49d3..87fd02e 100644 --- a/main.cpp +++ b/main.cpp @@ -1,11 +1,3 @@ -// -// main.cpp -// ranlin -// -// Created by Bob Polis on 05-03-15. -// Copyright (c) 2015 Thalictrum. All rights reserved. -// - #include #include #include @@ -20,9 +12,13 @@ double next_random() { } string random_line_from_file(istream& file) { + // This function selects a line from a file by reading + // the file line by line, so the file is never in memory + // as a whole. Still, the chance a line is being picked + // is equal for every line. string line; string result; - for (int nr {1}; getline(file, line); ++nr) { + for (int nr = 1; getline(file, line); ++nr) { if (next_random() * nr < 1.0) { result = line; }