Data commit

This commit is contained in:
Ingy döt Net 2023-07-01 11:58:00 -04:00
parent 7387c8f97b
commit cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions

View file

@ -0,0 +1,6 @@
void main() {
import std.stdio, std.file, std.string;
auto file_lines = readText("input.txt").splitLines();
//file_lines becomes an array of strings, each line is one element
writeln((file_lines.length > 6) ? file_lines[6] : "line not found");
}

View file

@ -0,0 +1,22 @@
import std.stdio;
void main() {
int countLines;
char[] ln;
auto f = File("linenumber.d", "r");
foreach (char[] line; f.byLine()) {
countLines++;
if (countLines == 7) {
ln = line;
break;
}
}
switch(countLines) {
case 0 : writeln("the file has zero length");
break;
case 7 : writeln("line 7: ", (ln.length ? ln : "empty"));
break;
default :
writefln("the file only contains %d lines", countLines);
}
}