Fix multiple file args

With multiple files, you would get a line for each file argument, but
only from the first file, never from any other file argument.
This commit is contained in:
2025-07-18 16:12:07 +02:00
parent e6eff86ef3
commit f0b3a15f91

View File

@@ -70,7 +70,7 @@ int main(int argc, char* argv[]) {
for (int i = optind; i < argc; ++i) {
try {
// process file argv[i]
ifstream infile {argv[1]};
ifstream infile {argv[i]};
cout << random_line_from_file(infile) << '\n';
} catch (const runtime_error& ex) {
cerr << "ranlin: " << ex.what() << '\n';